PHP - Moved: Need Php Email Script That Allow Multiple File Attachments
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=348632.0 Similar TutorialsJust 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?? 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 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 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 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"; } ?> 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" 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'; } 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\">"; } ?> 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. Hello, all: been trying to convert this little single-file upload to multiple by naming each file form-field as "userfile[]" as it's supposed to automatically treat them as an array.. but no luck! Can you guide me as to what am I doing wrong?? appreciate the help! Code: [Select] <?php if (!isset($_REQUEST["seenform"])) { ?> <form enctype="multipart/form-data" action="#" method="post"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> <input type="submit" value="Upload"> <input type="hidden" name="seenform"> </form> <?php } else { // upload begins $userfiles = array($_FILES['userfile']); foreach ($userfiles as $userfile) { // foreach begins $uploaded_dir = "uploads/"; $userfile = $_FILES['userfile']["name"]; $path = $uploaded_dir . $userfile; if (move_uploaded_file($_FILES['userfile']["tmp_name"], $path)) { print "$userfile file moved"; // do something with the file here } else { print "Move failed"; } } // foreach ends } // upload ends ?> 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"); } ?> Basically I have successfully found a function that can send email with attachment. However wasn't able to send multiple attachments. I tried sending two attachments manually, but only the second was successfully attached. Can someone look through the code below and point out my mistake. Thank you in advance.... <?php if(isset($_POST['send'])) { $fileatt_one = $_FILES['attachment']['tmp_name'][0]; $fileatt_type_one = "application/octet-stream"; // File Type $fileatt_name_one = $_FILES['attachment']['name'][0]; // Filename that will be used for the file as the attachment $fileatt_two = $_FILES['attachment']['tmp_name'][1]; $fileatt_type_two = "application/octet-stream"; // File Type $fileatt_name_two = $_FILES['attachment']['name'][1]; // Filename that will be used for the file as the attachment $email_from = "a@gmail.com"; // Who the email is from $email_subject = "Test"; // The Subject of the email $email_txt = "Testing 123"; // Message that the email has in it $email_to = "a@gmail.com"; // Who the email is too $headers = "From: ".$email_from; $file_one = fopen($fileatt_one,'rb'); $data_one = fread($file_one,filesize($fileatt_one)); fclose($file_one); $file_two = fopen($fileatt_two,'rb'); $data_two = fread($file_two,filesize($fileatt_two)); fclose($file_two); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $data_one = chunk_split(base64_encode($data_one)); $data_two = chunk_split(base64_encode($data_two)); $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" ."--{$mime_boundary}\n" ."Content-Type:text/html; charset=\"iso-8859-1\"\n" ."Content-Transfer-Encoding: 7bit\n\n" .$email_txt . "\n\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_one};\n" ." name=\"{$fileatt_name_one}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_one . "\n\n" ."--{$mime_boundary}--\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_two};\n" ." name=\"{$fileatt_name_two}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_two . "\n\n" ."--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } } ?> <form enctype="multipart/form-data" name="send" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="file" name="attachment[]" size="50" /> <input type="file" name="attachment[]" size="50" /> <input type="submit" name="send" value="Submit"> </form> Hi I'm not a coder so don't know how to write this myself. I'm very much of the copy and paste type. Basically I want a file to be downloaded and an email sent when either a link is clicked or a submit button is pressed. This is so that when a particular file hosted on my site (a pdf) is downloaded I am alerted to this by an email notification. Can anyone help me out with this? I assume that this can be done with PHP and MySQL but am open to suggestions. Thanks in advance for your help Stephen This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=357764.0 I know it needs a for loop, but i don't know where in the code i should be putting it? Code: [Select] function check_input($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } $_POST = array_map('check_input', $_POST); $sql="INSERT INTO testimonials (CustomerName, Town, Testimonial, SortOrder, Images) VALUES ({$_POST['customername']}, {$_POST['town']}, {$_POST['testimonial']}, {$_POST['sort_order']}, '$imgname' )"; } if (!mysql_query($sql,$con)) { die("<br>Query: $sql<br>Error: " . mysql_error() . '<br>'); } echo "<p align=center><b>1 testimonial added</b></p>"; mysql_close($con); Thanks in Advance, Steve Anyone know of a script that will allow you to upload a file and converts it to a specified file format? Folder layout: script/ script/videos/mp4/ } script/videos/ogg/ } folders for converted files from uploaded files script/videos/webm/ } script/videos/swf/ } Video player: Code: [Select] <video width="320" height="240" controls="controls"> <source src="script/videos/mp4/<? echo $movie; ?>.mp4" type="video/mp4" /> <source src="script/videos/ogg/ <? echo $movie; ?> .ogg" type="video/ogg" /> <source src="script/videos/webm/ <? echo $movie; ?> .webm" type="video/webm" /> <object data="script/videos/mp4/ <? echo $movie; ?> .mp4" width="320" height="240"> <embed src="script/videos/swf/ <? echo $movie; ?> .swf" width="320" height="240"> Your browser does not support video </embed> </object> </video> I have searched and searched the web for an answer and cannot find one pleas help? 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. 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. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 |