PHP - Email Pipe Script Won't Save Attachments.
Just as the title says.
In cPanel, I have it al configured just fine; the script recieves the email, and I do receieve an email back, but here's where I come into problems. It simply will NOT save the attachments to the server, I've tried loads of different implementations I've found, and nothing's working. pipe script: #!/usr/local/bin/php <?php // Need PEAR installed include('Mail.php'); include('Mail/mime.php'); require_once 'Mail/mimeDecode.php'; // read email using stdin $fx = fopen("php://stdin", "r"); $email = ""; while (!feof($fx)) { $email .= fread($fx,1024); } $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $params['input'] = $email; /* $message=new Mail_mimeDecode(); $mailObj=$message->decode($params); */ $mailObj = Mail_mimeDecode::decode($params); // Who is it from $from=$mailObj->headers['from']; // Get Subject $subj=$mailObj->headers['subject']; // Get Message Body $body=$mailObj->parts[0]->body; $gather="From:$from\nSubject:$subj\nBody:$body"; // Get and Save the Attachments foreach($mailObj->parts as $pp){ if ($pp->disposition=='attachment'){ $tmp=$pp->d_parameters['filename']; if($tmp !== ""){ $open = fopen($tmp, 'w'); if($open){ $write = fwrite($open,$pp->body); if(!$write){ $err = "Cannot write to file: '".$tmp."' - var: ".$write; } }else{ $err = "Cannot create/open file: '".$tmp."' - var: ".$open; } } } } $tox = $from; $subjectx = 'Your Photo was Uploaded!'; $messagex = $err; $headersx = 'From: piculo.us Uploader <upload@piculo.us>' . "\r\n" . 'Reply-To: upload@piculo.us' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($tox, $subjectx, $messagex, $headersx); exit; ?> Here's the email I get back: Cannot create/open file: '2879_1150712806251_1180540351_425140_7940412_n.jpg' - var: as you can see, it is aware that an attachment exists, but it won't create the file, and fopen() doesn't say anything. Any ideas?? Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348632.0 Hi all, Does anyone know how to extract attachments from an email that has more than one attachment associated with it? Getting the overall attachment data works fine using Code: [Select] <?php $attachment_data = imap_fetchbody($inbox,$email_number,2); ?> ..but breaking up that data into its component attachments is eluding me, and I can't find anything on the PHP doco that enabled me to do it. All info appreciated, WoolyG hi there. this is my first post. i'm sory for my english (i'm portuguese) i have i very bad situation. on my code. i'm sending an email from my aplication and when arrives to the client the Attachments is send with the extension ".dat". in my pc the email is sent correct. but from other pc (server) the extension arrives ".dat". does anyone have the same problem ??? please help me. tnks Hi, I have done this script that sends emails without attachments. What I want to do now is add the functionality to attach multiple files using one single field, kind of what Outlook does...you can select one or more files to attach to your email. Any ideas how I can do this? Thanks Code: [Select] <?php $EmailTo = Trim(stripslashes($_POST['to'])); $Subject = Trim(stripslashes($_POST['subject'])); $email = Trim(stripslashes($_POST['email'])); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: My company<info@mycompany.com>' . "\r\n"; $headers .= "Cc: {$_POST['cc']}\r\n"; $headers .= "Bcc: {$_POST['bcc']}\r\n"; // prepare email body text $Body = ""; $Body .= $email; $Body .= "\n"; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, stripslashes($Body), $headers); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../PC_email_compose.php?emailsentok=true\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../PC_email_compose.php?emailsenterror=true\">"; } ?> I am piping email to a php script, from the email I want to get the email attachment that came with it. For our sake, the curent attachment I am working with is jpg. how can I get an image that is base64 encoded, then save it to a jpg file? "Content-Transfer-Encoding: base64" Hi all I'm trying to send an automated email of a zip file. However it seems to be just reading the files into the body of the mail rather than attaching a single zip archive containing several files. I receive the mails, but I effectively want a blank message body with a zip file attached. Please see code below, any ideas why this is not working. I'm a bit of a newbie and never used this before so any pointers would be good. <?php //Send Zip file as attachment //Set Email and attachment details $to = "me@123.com"; $from = "Visionnet <DO_NOT_REPLY>"; $subject = "Subject"; $message = "Please see attached file"; $fileatt = "wiki_zip.zip"; $fileatt_type = "application/zip"; $fileatt_name = "wiki_zip.zip"; //Read in the attachment $file=fopen($fileatt,'rb'); $data=fread($file,filesize( $fileatt)); fclose($file); //Add the MIME content $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the Headers for file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $message = "This is a multipart message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; //Base64 encode file data $data = chunk_split(base64_encode($data)); //Add attachment to message $message .= "--{mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; //Send message $ok = @mail($to, $subject, $message, $headers, "$from"); if($ok) { echo "mail sent"; } else { echo "mail failed"; } ?> Hello I have a database table containing users uploaded word docs as long blobs (I know in an ideal world these should be in a filesystem, not a table but that wasn't possible) I'd like to be able to generate an email with php and send out these files as attachments. I have pear mail installed and can get this to send out emails with attachments form a file share no problems. Getting it to work with blobs escapes me though. Is this possibile of do I need a different class? Code: [Select] include('../db_connection.php'); $query1 = "SELECT id, name, type, content, size FROM upload WHERE lref='" . $_POST['lref'] . "'"; $result2 = $mysqlilsr->query($query1) or die ($mysqlilsr->error); list($id, $name, $type, $content, $size) = $result2->fetch_array(); //echo $name . '<br/>'; //echo $content . '<br/>'; //echo $type . '<br/>'; //$fileattname = file_get_contents($_POST['attachment']); $fileattname = file_get_contents($_POST['attachment']); $from_mail = "email address"; $replyto = "email address"; //phpinfo(); //mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message); $headers = array( 'From' => $from_mail, 'Subject' => $subject, 'Cc' => $replyto, ); $body = $header . $spacer .$message . $spacer . $footer; $mime = new Mail_mime(); $mime->setTXTBody($body); $mime->addAttachment(base64_encode($content), $name, $type, "iso-8859-1"); $body = $mime->get(); $headers = $mime->headers($headers); $mailer =& Mail::factory('mail'); $res = $mailer->send($_POST['email'], $headers, $body); if (PEAR::isError($res)) { echo 'error'; } else { 'success'; } Hey All, I am having issues understanding how this works. I am trying to do a quote and send out 5 images of the product. I cannot seem to get how I get the images sent with the email. If anyone can take a look I would greatly appreciate it. PHP <?php $email = $_POST ['email']; $quote = $_POST ['quote']; $item = $_POST ['item']; $inventory = $_POST ['inventory']; $category = $_POST ['category']; $manu = $_POST ['manu']; $model = $_POST ['model']; $condition = $_POST ['condition']; $dimension = $_POST ['dimension']; $desc = $_POST ['desc']; $skidprice = $_POST ['skidprice']; $unitprice = $_POST ['unitprice']; $totalprice = $_POST ['totalprice']; $img1 = $_POST ['img1']; $img2 = $_POST ['img2']; $img3 = $_POST ['img3']; $img4 = $_POST ['img4']; $img5 = $_POST ['img5']; //Get the uploaded file information $name_of_uploaded_file = basename($_FILES['uploaded_file']['name']); //get the file extension of the file $type_of_uploaded_file = substr($name_of_uploaded_file, strrpos($name_of_uploaded_file, '.') + 1); $size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;//size in KBs //Validations if($size_of_uploaded_file > $max_allowed_file_size ) { $errors .= "\n Size of file should be less than $max_allowed_file_size"; } //------ Validate the file extension ----- $allowed_ext = false; for($i=0; $i<sizeof($allowed_extensions); $i++) { if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0) { $allowed_ext = true; } } if(!$allowed_ext) { $errors .= "\n The uploaded file is not supported file type. ". " Only the following file types are supported: ".implode(',',$allowed_extensions); } //copy the temp. uploaded file to uploads folder $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file; $tmp_path = $_FILES["uploaded_file"]["tmp_name"]; if(is_uploaded_file($tmp_path)) { if(!copy($tmp_path,$path_of_uploaded_file)) { $errors .= '\n error while copying the uploaded file'; } } // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; // More headers $headers .= 'From: All Food Equipment<sales@allfoodequip.com>' . "\r\n"; $headers .= "Message-ID: <".$now." sales@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $subject = "Your All Food Equip Quote"; $msg = " <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\"> <html> <head><link href=\"http://www.allfoodequip.com/admin/quote/style.css\" rel=\"stylesheet\" type=\"text/css\"></head> <body> <div id=\"container\" style=\"width:960px; height:auto; margin:0 auto; border-right: 2px solid #666; border-left: 2px solid #666;\"> <div id=\"header\" style=\"background-image:url(http://www.allfoodequip.com/admin/quote/images/banner_bg.jpg); width:100%; height:149px;\"></div> <!--Closes header--> <div id=\"subHead\" style=\"background-image:url(http://www.allfoodequip.com/admin/quote/images/menu_bg.jpg); width:100%; height:42px;\"></div> <!--closes subHead--> <div class=\"contents\" style=\"background:#f2f1f1; padding-right: 25px; padding-left: 25px;\"> <h1 style=\"margin:0px;padding:10px 0 5px;font-size:18px;\">Your All Food Equipment Quote:</h1> <table width=\"700\" border=\"0\" class=\"table\" style=\"padding:0px 0px 15px;\"> <tr> <td width=\"119\">Quote #:......................................................... </td> <td width=\"208\">$quote</td> </tr> <tr> <td>Item:..............................................................</td> <td>$item</td> </tr> <tr> <td>Inventory:.......................................................</td> <td>$inventory</td> </tr> <tr> <td>Category:.......................................................</td> <td>$category</td> </tr> <tr> <td>Manufacturer:.................................................</td> <td>$manu</td> </tr> <tr> <td>Model:...........................................................</td> <td>$model</td> </tr> <tr> <td>Condition:......................................................</td> <td>$condition</td> </tr> <tr> <td>Dimension:....................................................</td> <td>$dimension</td> </tr> <tr> <td>Description:...................................................</td> <td>$desc</td> </tr> <br> <tr> <td><b>Skid Price:</b>.................................................</td> <td><b>$skidprice</b></td> </tr> <tr> <td><b>Unit Price:</b>.................................................</td> <td><b>$unitprice</b></td> </tr> <tr> <td><b>Total Price:</b>................................................</td> <td><b>$totalprice</b></td> </tr> </table> <div class=\"t_middle\"> <img name=\"Img\" src=\"$img1\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img2\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img3\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img4\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"><img name=\"Img\" src=\"$img5\" width=\"177\" height=\"115\" alt=\"Img\" style=\"background-color: #999999\"> </div> <div class=\"break\" style=\"padding: 15px 0px; width:100%;\"><hr></div> <!--break--> <!--close t_middle--> <div class=\"contactUs\"> <p style=\"color:#650035;\">How to contact us:</p> <ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\"> <li>Visit us Online: www.allfoodequip.com</li> <li>Contact: Dino Roberts</li> <li>Direct Line: 615-788-2953 </li> <li>Email: dino@allfoodequip.com</li> </ul> <ul class=\"contact_list\" style=\"margin:0px;padding:0px;color:#650035;line-height:25px;padding-bottom:30px;list-style:none;\"> <li>All Food Equipment</li> <li>1240 Industrial Park Road</li> <li>Columbia, TN 38401</li> <li>Main Office: 931-490-1977</li> </ul> </div> <p style=\"font-size:14px;color:#333;\">TERMS & CONDITIONS: </p> </div> <!--close m_disc--> <div id=\"footer\" style=\"clear: both; width: 100%; padding: 20px 0 20px 0; text-align: center; border-top: 1px solid #8b8a8b; background: #343233 url(http://www.allfoodequip.com/admin/quote/images/footer.jpg) no-repeat;\"> <ul class=\"footer_list\" style=\"margin:0px;padding:0px;list-style:none;\"> <li style=\"padding: 0 10px; display: inline; border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com\" style=\"color: #cccccc; text-decoration: none;\">Home</a></li> <li style=\"padding: 0 10px; display: inline; border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/new-equipment.php\" style=\"color: #cccccc; text-decoration: none;\">New Equipment</a></li> <li style=\"padding: 0 10px; display: inline; border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/used-equipment.php\" style=\"color: #cccccc; text-decoration: none;\">Used Equipment</a></li> <li style=\"padding: 0 10px; display: inline; border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/services.php\" style=\"color: #cccccc; text-decoration: none;\">Services</a></li> <li style=\"padding: 0 10px; display: inline; border-right: 1px solid #cccccc;\"><a href=\"http://www.allfoodequip.com/about-us.php\" style=\"color: #cccccc; text-decoration: none;\">About Us</a></li> <li class=\"last\" style=\"padding:0 10px;display:inline;border-right:none;\"><a href=\"http://www.allfoodequip.com/contact-us.php\" style=\"color: #cccccc; text-decoration: none;\">Contact Us</a></li> </ul> <div class=\"margin_bottom_10\"></div><br> <span style=\"color:#FFF;\">Copyright © 2010 </span> - <a href=\"http://www.allfoodequip.com\"><font color=\"#FFFFCC\">All Food Equipment</font></a> <div class=\"margin_bottom_10\"></div> <!-- end of footer --> </div> <!--container--> </div> </body> </html> "; // MAIL SUBJECT $subject = "Your All Food Equip Quote"; // TO MAIL ADDRESS $to="$email"; mail($to, $subject, $msg, $headers); // Redirect header("Location: Admin.php?Msg=Sent"); ?> Heres the HTML side of it. Code: [Select] <label for="img1">Image 1:</label> <input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img1"> <label for="img2">Image 2:</label> <input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img2"> <label for="img3">Image 3:</label> <input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img3"> <label for="img4">Image 4:</label> <input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img4"> <label for="img5">Image 5:</label> <input type="hidden" name="MAX_FILE_SIZE" value="2500000"> <input type="file" name="img5"><br /> Thanks in advance. I have a script that generates an excel spreadsheet, and attaches it to an email ready for mailing. Now, I can make it email the attachment no problem. I have searched for solutions on inserting 3 images in the email as well, but to no avail. I found a script that I thought could work, but it just sends the script via email and nothing else. Does anybody know of a good way to do this? Perhaps someone can help me with this script? <?php include "get_contact_list.php"; ################################################################################ ########### ### An email script that will attach images inline in an HTML and plain text e-mail ### ### Just enter you own email infomation and file names with paths where indicated in ### ### the script. Have fun with it alter it add to it or whatever you want. When you are ### ### done reading all the confusing tutorials about this kind of using mail to send your ### ### own without PHPmailer then you can just use this file to suit your self. ### ################################################################################ ########### $to = 'xxxxxxx@xxxxx.com';// same as above $subject = 'CONTACT & SUPERVISORS LIST_'.$date;//your own stuff goes here // Create a boundary string. It needs to be unique $random_hash = sha1(date('r', time())); // Add in our content boundary, and mime type specification: $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; // Read in our file attachment $attachment = file_get_contents($path); $encoded = base64_encode($attachment); $attached = chunk_split($encoded); // additional headers $headers = "From: Nxxxxxx Cxxxxxx <xxxxxxxx@xxxxx.com>" . "\r\n" . 'Reply-To: xxxxxxxx@xxxxx.com' . "\r\n";//put you own stuff here or use a variable $inline = chunk_split(base64_encode(file_get_contents('../../images/emails/vcelogo.jpg'))); // Your message he ob_start();?> --PHP-mixed-<?php echo $random_hash; ?>-- Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>--" --PHP-alt-<?php echo $random_hash; ?>-- Content-Type: text/plain Hai, Its me! --PHP-alt-<?php echo $random_hash; ?>-- Content-Type: multipart/related; boundary="PHP-related-<?php echo $random_hash; ?>--" --PHP-alt-<?php echo $random_hash; ?>-- Content-Type: text/html <html> <head> <title>Test HTML Mail</title> </head> <body> <font color='red'>Hai, it is me!</font> Here is my pictu <img src="cid:PHP-CID-<?php echo $random_hash; ?>" /> </body> </html> --PHP-related-<?php echo $random_hash; ?>-- Content-Type: image/jpeg; Content-Transfer-Encoding: base64 Content-ID: <PHP-CID-<?php echo $random_hash; ?>--> <?php echo $inline; ?> --PHP-related-<?php echo $random_hash; ?>-- --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?>-- Content-Type: application/vnd.ms-excel; name='CONTACT & SUPERVISORS LIST_'.$date.'.xls'; Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php $body = ob_get_clean(); // Finally, send the email $send = mail($to, $subject, $body, $headers); if ($send) { unlink($path); header("Location: hr_options.php?message=Sent successfully"); } else { header("Location: hr_options.php?message=Failed Sending"); } ?> Hi I'm very new to PHP. I've been searching high and low for a script that will process a simple form and also allow a file attachment. I've tried loads of different ones and none of them work as I want. I do actually have one working but this doesn't have any validation of the file. Can anyone please point me in the direction of a script that will allow me to do this. Thanks I would like to store PDF file into mysql (this part works) and then send it as email attachment and it should be retrieved from mysql table. Here's the code I have for now, but what it gives me is 0bytes large PDF file Saving PDF to mysql (it works), because size of blob in mysql table is OK. $fp = fopen('generated.pdf', 'r'); $content = fread($fp,filesize('generated.pdf')); $content = addslashes($content); fclose($fp); $DB->Query('insert into pdf_files (pdf_file, name) values ("'.$content.'", "'.$name.'")'); And here's the mailing part <?php $query = "SELECT name, pdf_file FROM pdf_files $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array ( $result)) { $fileContent =$row['pdf_file']; $fileName=$row['name']; } $fileatt = $fileContent; // getting file $fileatt_type ="application/pdf"; //type of file $fileatt_name = "attachment.pdf"; // name $fileatt_size = $fileSize; $email_from = "dont@have.it"; // mail from $email_subject = "Testtt"; // subject $email_message = "Testtt.<br>"; $email_message .= "Testtt.<br>"; // Message $email_to = $mail_user; // users mail $headers = "From: ".$email_from; $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "Testtt.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data .= "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2><center>Mail was sent</center>"; } else { die("Error!"); } ?> Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } Hi, n0obie here. I'm trying to identify where my customers are coming from via emails I've sent/received. However, many email providers (namely Gmail) have circumvented this by disallowing IP address geolocation/image caching. I found this site: http://www.wallpaperama.com/forums/how-to-save-html-output-code-from-php-script-t6898.html it demonstrates how to save html output code from php script. here is an example: http://ads4agents.com/date.php I cant get it to work on my site...where is the correct place ad these: ob_start(); $HtmlCode= ob_get_contents(); ob_end_flush(); How can I get this to work in my php? view_ad.php <html> <body> <center> <br/> <h1>Apartment Reference #: <?php echo $_POST["reference"]; ?><br /></h1> <br/> <?php echo $_POST["application"]; ?>, <?php echo $_POST["deposit"]; ?><br /> <?php echo $_POST["pets"]; ?><br /> <br/> <?php echo $_POST["community"]; ?><br /> <?php echo $_POST["interior"]; ?><br /> <?php echo $_POST["amenities"]; ?><br /> <br/> <?php echo $_POST["contact"]; ?><br /> <a href="<?php echo $_POST['website'] ?>"><?php echo $_POST['website'];?></a><br/> <br/> <br/> <br/> </body> </html> I am looking for the code|script to put on my update.php that allows uploaded images to be saved in my database (chmod) 777? PLEASE HELP! Hi Everyone! Thanks in advance for taking the time to review my post. I am pretty new to PHP so please excuse my ignorance. I am working a project for myself. I want to be able to send out newsletters to my customers and sponsors. I have written the code and here it is: <?php $subject = $_POST['subject']; $message = $_POST['message']; $email = "bubba@bubba.com"; $headers = "From: $email"; $email_list = file("elist.txt"); $total_emails = count($email_list); for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to = implode(",",$email_list); if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> ----------------------------------------------------------------------------- In my elist.txt file - I have two fields. Name and email. Bubba|bubba@bubba.com Oohay|oohay@yahoo.com If i leave the names out of this file, the email script works great! I want to leave the names in there and reference them in my email that I am sending out to be more personal. Can this be done and can you help? Thanks! Mike Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Hi, I have made a basic html site and it has two forms on it. I have the forms linking to a file called process.php. Basically i need to know what code to put in the php file in order for the forms to save whatever is entered in them to a txt file on my server or computer. Or any other easier way to do the same thing, save the content of two forms on my site. Hope i posted this in the right forum subject. Thanks very much for anyone that helps. Hey all, Let's say I want to do something like this: Code: [Select] <?php function exists($a){ $b ||= $a; } echo exists(1); ?> Basically, every time exists is called, it will only assign b to a if b isn't already initialized. What's the most effective way to achieve the equivalent in php? ternary? Thanks for response. |