PHP - Send Multiple Attachments
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> Similar TutorialsHello, i have this code for sending email it works great but i don't know where to start in sending emails with a pdf file attached ex: test.pdf. Any suggestions? <?php session_start(); require_once('framework/framework.php'); include('framework/class.smtp.inc'); //--- databse settings $dsn = array( 'dbtype' => 'mysql', 'username' => '', 'password' => '', 'host' => '', 'database' => '' ); try { $db = db::connect($dsn); } catch (Exception $e) { die($e->getMessage()); } //--- $subject="Formular online pentru participantii Diaspora Stiintifica 2010"; // +-------------- BEGIN ---- Functia de trimitere mail prin smtp -------------------+ */ function trimite($destinatar='', $subiect='', $mesaj='') { //--- mail settings $smtp_server_host="mail.server.com"; $smtp_server_port="25"; $sender="email@email.com"; $return_path="email@email.com"; $smtp_username="email@email.com"; $smtp_pswd="123"; /*************************************** ** Setup some parameters which will be ** passed to the smtp::connect() call. ***************************************/ $params['host'] = $smtp_server_host; // The smtp server host/ip $params['port'] = $smtp_server_port; // The smtp server port $params['helo'] = exec('hostname'); // What to use when sending the helo command. Typically, your domain/hostname $params['auth'] = false; // Whether to use basic authentication or not // $params['user'] = $smtp_username; // Username for authentication // $params['pass'] = $smtp_pswd; // Password for authentication $params['timeout'] = '60'; /*************************************** ** These parameters get passed to the ** smtp->send() call. ***************************************/ $send_params['recipients'] = $destinatar; // The recipients (can be multiple) $send_params['headers'] = array( "MIME-Version: 1.0", "X-Mailer: PHP/" . phpversion(), "Return-Path: ".$return_path, "From: ".$sender, "To: ".$destinatar, "Subject: ".$subiect, "Content-type: text/html; charset=UTF-8", "Content-Transfer-Encoding: 8bit"); $send_params['from'] = $sender; // This is used as in the MAIL FROM: cmd // It should end up as the Return-Path: header $send_params['body'] = $mesaj; /*************************************** ** The code that creates the object and ** sends the email. ***************************************/ $smtp = new smtp($params); $smtp->connect(); $trimis=$smtp->send($send_params); $raspuns=array($destinatar, $trimis, $smtp->errors); // $smtp->rset(); //--- Bcc: /* $send_params['recipients'] = $sender; $trimisi=$smtp->send($send_params); $errmsgi=$smtp->errors; print "<br>bcc: ".$send_params['recipients']."; ".$trimisi."<br>"; for ($n = 0 ; $n <= count($errmsgi) - 1; $n++) { print "<br>"." bccerr: <strong>".$errmsgi[$n]."</strong><br>"; } */ $smtp->quit(); return $raspuns; } // +-------------- END ---- Functia de trimitere mail prin smtp -------------------+ */ // +---------------------------------------------------------------------------+ $afisez = ""; $cond=0; $query = "SELECT email_1 FROM inregistrari WHERE `completat`=0"; $useri = $db->getAll($query); $i=0; $j=0; $k=0; foreach ($useri as $row) { $tpl = new HTML_Template_Sigma('mesaj'); $tpl->loadTemplateFile("mesaj.html"); $tpl->setVariable($row); $html=$tpl->get(); //*/ $html=nl2br($html); $html=str_replace(chr(10), "", $html); $html=str_replace(chr(13), "", $html); // */ // +----------------------+ $subiect = $subject; if (!empty($row['email_1'])) { $subelements=preg_split("/, /", $row['email_1'], -1, PREG_SPLIT_NO_EMPTY); for ($m = 0 ; $m <= count($subelements) - 1; $m++) { $rez = trimite($subelements[$m], $subiect, $html); if ($rez[1]==true) { $afisez .= $rez[0].";1<br>"; $i++; } else { $afisez .= $rez[0].";0<br>"; $errmsg=$rez[2]; for ($n = 0 ; $n <= count($errmsg) - 1; $n++) { $afisez .= " <strong>".$errmsg[$n]."</strong><br>"; } $j++; } } } else { $afisez .= $row['email_1'].";no email;n<br>"; $k++; } } $afisez .= "<br>{$i} mesaje Trimise<br>"; $afisez .= "{$j} mesaje Netrimise<br>"; $afisez .= "{$k} mesaje fara adresa<br>"; print $afisez; ?> 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"); } ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348632.0 I have a page that adds name and date of birth of an actor. <input type='text' id='name' name='name' value=''/> <input type='text' id='dob' name='dob' value=''/> But I made a loop that enables the user to add multiple actor information at once, so the page will actually look like this. (if you can imagine how it would look on a website with these php codes) <input type='text' id='name' name='name' value=''/> <input type='text' id='dob' name='dob' value=''/> <input type='text' id='name' name='name' value=''/> <input type='text' id='dob' name='dob' value=''/> <input type='text' id='name' name='name' value=''/> <input type='text' id='dob' name='dob' value=''/> <input type="submit" Value="Add"/> How do I send all 3 of these actor information into my saving page instead of just 1 and how do I save all 3 in that saving page? I have a HTML form with a drop down list, which has my entire buyers list populated from the database. In addition to that, I have an option on the top of the drop down such as :
<select name="sms_buyer"> <option value="alll">ALL</option> <?php require_once '../model/notifications.php'; @$result2= Notifications::getAllBuyers(); while($value2=mysql_fetch_assoc($result2)){ ?> <option value="<?php echo $value2['buyer_code']; ?>"> <?php echo $value2['buyer_name'] ?> </option> <?php } ?> </select>In the Controller I have the following code segment: function sendNotificationSMS(){ $sms_buyer=$_REQUEST['sms_buyer']; $sms_message=$_REQUEST['sms_message']; $sender='MY CLIENT'; $url='http://localhost:9333/ozeki?'; $url.="action=sendMessage"; $url.="&login=admin"; $url.="&password=abc123"; $obj=new Notifications(); if($sms_buyer=='alll'){ require_once '../model/notifications.php'; $obj=new Notifications(); $result=$obj->getAllBuyers(); while($value=mysql_fetch_assoc($result)){ $rec[]=$value['tel_no']; } foreach ($rec as $recepient) { $url.="&recepient=".urlencode($recepient); } } else{ $res=$obj->getBuyerTelNo($sms_buyer); $sms=mysql_fetch_assoc($res); $recepient=$sms['tel_no']; $url.="&recepient=".urlencode($recepient); } $message=$sms_message; $message.=' Thank You.'; $url.="&messageData=".urlencode($message); $url.="&sender=".urlencode($sender); file($url); header("location:../view/send_notifications.php?s=3#sent"); }If I type print_r($url), the output which I am intending is not appearing... Sending SMS to a single recepient is fine. The problem is sending sms to multiple recepients. Any help is appreciated. Thanks. Hello, I am new in PHP and I want a script for sending multiple emails using the php and i am calling that email address from database.I also want to change the status field from database from No to Yes once I send the particular emails. How to do that? I need a urgent help Following is my code for calling the email address <? mysql_connect("localhost","root","123") or die(mysql_error()); // my database connection mysql_select_db("localacct") or die(mysql_error()); $sql = "SELECT email FROM company where status='No'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res) ) { $area .= $row['email']. ", "; } // read the list of emails from the file. $email_list = explode(',', $area); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to = $email_list; //echo $to; $t0 = ""; $subject = "Test email"; $message = wordwrap($message, 100); $from = "my email address"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: $from"; mail($to,$subject,$message,$headers); if ($count % 10 == 0) { sleep(5); // this will wait 5 secs every 10 emails sent, and then continue the while loop } $count++; } ?> Many Thanks in advance. This will only send 1 goggles information into the database but I have a "adding" page that can actually add more than 1 goggles at once. I have no idea how to go about saving multiple goggle's information using array or loop. $name= $_POST['goggles_name']; $price = $_POST['goggles_price']; $des = $_POST['goggles_description']; $file = $_FILES['goggles_image']['name']; $chkbox = $_POST['upload']; $id = $_POST['goggles_id']; $query = "UPDATE goggles SET goggles_name = '$name' , goggles_price = '$price' ,goggles_description = '$des' WHERE goggles_id ='".$id."' "; $result = mysqli_query($link, $query) or die(mysqli_error($link)); How do I send multiple headers with this code? Code: [Select] <?php $postdata = http_build_query( array( 'var1' => 'some content', 'var2' => 'doh' ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://example.com/submit.php', false, $context); ?> *this header: Code: [Select] User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16 Dear all, Hopefully someone can help me out with this. I have a HTML form wich contains basic textfields en checkboxes. Beyond that i have a row with some dropdowns, but one of these fields in the row is a file field. Also, the visitor is able to add a new row, when the user clicks add row, a new row with the same fields including a new file field appears. This can be done as much as the user likes. The fiel field is optional though, it doesn't need to be filled. All my textfields, checkboxes and dropdowns are coming through email nicely. Only thing that isn't coming my way are the files i attach. My form (stripped but functional) can be seen here http://www.multisearch.info/test/form_test.html For the file fields i take it you need an array wich i have put in the form Code: [Select] <input type="file" name="fileupload[]"> In my PHP wich handles the form i have this wich should handle the images, but this is not working Code: [Select] if(isset($_POST['submit'])) { for($i=0;$i<count($_FILES['fileupload']);$i++) { print $_FILES['fileupload']['name'][$i]."<br />"; } } I hope someone sees something i am missing. Kind regards, Jeroen Hi
First time post. I have read online and there are so many different answers I do not know which to choose.
I have a form on a website which works fine as it is.
I just want to add a function that when the the visitor clicks submit they get a copy of the email as well.
This is the code I have:
<p>Please read through our terms of business below. If you are happy with them and understand them please complete your details and press the agree button. We will email confirmation of receipt</p> <div class="content_image"> <img src="images/questionnaire.jpg" alt="" width="350" height="225" /> </div> <form id="questionnaire" method="post" action="terms-of-business-send.php" name="questionnaire"> <fieldset> <div> <label>Your Full Name:</label><br /> <input type="text" id="c_name1" name="c_name1" class="qfield clear" /> </div> <div> <label>Your Email:</label><br /> <input type="text" id="email" name="email" class="qfield clear" /> </div> <div> <label>Your Contact Tel:</label><br /> <input type="text" id="tel" name="tel" class="qfield clear" /> </div> </fieldset> <fieldset> <ol> <li> <h2>I agree I have read and understood the terms of business</h2> <input type="radio" name="q1" value="1" /> yes I agree<br /> </li> </ol> <div> </div> </fieldset> <input type="submit" value="Agree"> <input type="reset" value="Reset"> <h4 id="error">There were errors on the form, please make sure your name and email have been filled out correctly.</h4> </form> Then the send file is <?php $c_name1 = $_POST['c_name1']; $email = $_POST['email']; $tel = $_POST['tel']; $q1 = $_POST['q1']; //$to = 'enquiries@email.net'; $to = 'enquiries@cemail.net'; $subject = 'Terms of Business Completed'; $msg = "$c_name1 has completed a Terms of Business from.\n\n" . "Their email is: $email\n" . "Their contact number is: $tel\n" . "-----------------------------\n\n" . "1: $q1\n\n" . "Terms of business copy here" . "-----------------------------\n" . " END OF FORM -------\n" . "-----------------------------\n\n"; mail($to, $subject, $msg, 'From: website Terms of Business Form'); echo '<h2>Thanks for confirming our Terms of Business ' . $c_name1 . '</h2>'; ?> I kind of understand what is going on but am not proficient enough. Any help much appreciated. Rich i want to send email to multiple user.this is my code: Code: [Select] <?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $dropdown = $_POST['dropdown']; $formcontent=" From: $firstname \n Surname: $lastname \n Email: $email \n Dropdown: $dropdown"; $recipient = "martin@sittingspiritually.co.uk, siobhan@sittingspiritually.co.uk"; $subject = "Newsletter Sign Up"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); if ( mail($recipient, $subject, $formcontent, $mailheader) ){ header('Location: http://www.sittingspiritually.co.uk/thankyou.php'); } else { die ("error"); } ?> I have recently created a small snippet of php code for posting mail and it's sweet apart from 1 thing. I have two email addresses in the recipient section. It only sends to the last name in the list. Is this because i have written recipient? Should it be recipients? I need this mail to be delivered to both of the email addresses. I'm sure it's simple for someone with expert knowledge. Thanks in advance for any help. I am trying to send an e-mail message from a form, to each person in a MySQL database. In some cases, but not all, there are multiple e-mail address in the recordset. Each one should receive the same message addressed to them by name (FirstName and LastName) and e-mail address. I have tried "CONCAT_WS(' ', emailtest.Pri_EmailAddress, emailtest.Sec_EmailAddress, emailtest.Tri_EmailAddress) AS EmailTo" but it seems the relay account is rejecting the message if more than one address is in the EmailTo result. Any ideas or scripts that can do this would be appreciated. Thank you in advance for your help. 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 How do u work with .jpg file attachments using the IMAP mail functions... i already know how to read the body text from an e-mail with IMAP but I haven't worked with attachments and don't know where to start... i basically want to get the .jpg attachment and save it to a folder on my server. Hello, so I have been able to successfully use the imap_mail_compose function to generate a valid and working MIME message string. However, when trying to add an attachment, the MIME message never contains the attachment., What am I doing wrong?
$envelope["from"]=$_SESSION['username']; $envelope["to"]=$_POST['To']; $envelope["cc"]=$_POST['Cc']; $envelope["bcc"]=$_POST['Bcc']; $envelope["subject"]=$_POST['Subject']; $part1["type"] = TYPEMULTIPART; $part1["subtype"] = "mixed"; $part2["type"]=TYPETEXT; $part2["subtype"]="plain"; $part2["contents.data"]=$_POST['Message']; $uploaddir = "C:\\inetpub\\wwwroot\\PHPTesting\\uploads\\"; $uploadfile = $uploaddir.$_FILES['Attachment']['name']; move_uploaded_file($_FILES['Attachment']['tmp_name'], $uploadfile); $fp = fopen($uploadfile, "r"); $contents = fread($fp, filesize($uploadfile)); fclose($fp); $part3["type"] = $_FILES['Attachment']['type']; $part3["encoding"] = ENCBINARY; $part3["description"] = basename($uploadfile); $part3["contents.data"] = $contents; $body[1]=$part1; $body[2]=$part2; $body[3]=$part3; $mime = imap_mail_compose($envelope, $body); 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, is there a way to generate attachemtns for php's mail() function on the fly, without first saving a file. I have an html page stored in a variable and would like to send it as both the body of the mail and as an attachment in it (well actualy I would like to just send it in the body....). Can I push the variable as an attachement or do I need to generate a temp file from it first? Cheers Hi I am creating a simple program to send e-mail. It contains 2 pages, index.php and sendmail.php Here is the code of index.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Send Mail #1</title> </head> <body> <p> </p> <p> Mail 1</p> <form id="form1" name="form1" method="post" action="sendmail.php"> <table width="821" height="240" border="0"> <tr> <td width="168">To :</td> <td colspan="2"><label> <input name="to_textbox" type="text" id="to_textbox" size="75" /> </label></td> </tr> <tr> <td>Subject :</td> <td colspan="2"><label> <input name="subject_textbox" type="text" id="subject_textbox" value="" size="75" /> </label></td> </tr> <tr> <td>From :</td> <td colspan="2"><label> <input name="from_textbox" type="text" id="from_textbox" value="" size="75" /> </label></td> </tr> <tr> <td>Content :</td> <td colspan="2"><label> <textarea name="content_textbox" id="content_textbox" cols="75" rows="5"> </textarea> </label></td> </tr> <tr> <td> </td> <td width="153"><label> <input type="submit" name="send_button" id="send_button" value="Send..." /> </label></td> <td width="486"><label> <input type="reset" name="reset_button" id="button" value="Reset" /> </label></td> </tr> </table> <p> </p> <p> </p> <p> </p> </form> <p> </p> </body> </html> Code for sendmail.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $to = $_POST["to_textbox"]; $from = $_POST["from_textbox"]; $subject = $_POST["subject_textbox"]; $message = $_POST["content_textbox"]; $headers = "From: " . $from . "\r\n"; $mailsent = mail($to, $subject, $message, $headers); if ($mailsent) { echo " <center> Congrats ! The message has been sent </center>"; echo " <center><b>\n To: $to </b></center>"; } else { echo " There was an error..."; } ?> </body> </html> How can I add attachments ? I want to add few photos (.jpg) I searched on google but found nothing which can relate with mail() |