PHP - Php Mail Function Using $to Or $email?
Please would somebody be able to show me or give me some tips as to how I go about getting an email to send in my php code?
$headers = 'From: me@me.com' . "\r\n" . 'Reply-To: me@me.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $first = $_GET['first']; $last = $_GET['last']; $town = $_GET['town']; $telephone = $_GET['telephone']; $code = $_GET['postcode']; $shortcode = substr($code,0,2); $query =mysql_query ("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3"); echo mysql_error(); echo "<p>The email addresses you have requested are;</p>"; while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; echo "$nt[0]<br>$nt[1]<br>$nt[2]<br>"; $message = "$first . $last, from $town has searched for your details.<br>You may contact them on $telephone. <br> Thankyou."; $subject = "You Showed Up In The Tree Directory!"; $email = "$nt[0],$nt[1],$nt[2]"; $to = "$email"; mail( "$to", "$subject","$message", "$headers"); ?></body></html> Similar TutorialsEverything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Hi, I need to check is the mail is sent and successfully deliver to the recipient email. here is the code : if(mail($to, $subject, $message, $headers, '-f ' . $return_path)) {echo "Sent"; }else {echo "Not Sent";} Please help me, its urgent. Thanks in advance. Hello Everyone I have written a simple mail function to be emailed to a certain person on submission. On submission they would also like to have attachments sent to them. I got the email being sent but I can;t get the attachments to work. I have read several different examples and tutorials and none of them work. This is my code so far without any code for file attachment <?php $project_name = $_POST['project_name']; $needed = $_POST['date_needed']; $submitted = $_POST['date_submitted']; $department = $_POST['department']; $contact = $_POST['contact_person']; $extension = $_POST['extension']; $project_type = $_POST['project_type']; $published = $_POST['date_last_published']; $description = $_POST['description']; $color = $_POST['color']; $pdf = $_POST['pdf_needed']; $web = $_POST['web_needed']; $quanity = $_POST['quanity']; $email = "mdmartiny@sc4.edu"; $subject = "SC4 Graphics Design Service Request Form"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "<html><body> <table width=\"100%\" border=\"0\" cellspacing=\"5px\" > <tr><td></td> <td>Project name: $project_name</td> <td></td> <td>Date needed by: $needed</td> </tr> <tr> <tr> <td></td> <td colspan=\"3\" align=\"left\" valign=\"top\"><strong><font size=\"+1\">Submitted to graphic designer</font></strong></td></tr> <tr><td height=\"25\"></td><td>Date $submitted</td><td>Department $department</td><td></td></tr> <tr><td height=\"25\"></td><td>Contact Person $contact</td><td>Extension $extension</td><td></tr> <tr><td height=\"25\"></td><td>Type of project $project_type</td><td colspan=\"2\">Approximate date of last publication $published</td></tr> <tr><td height=\"25\"></td><td colspan=\"3\">Project description/special instructions</td> <tr><td></td>><td colspan=\"3\">$description</td></tr> <tr><td height=\"25\"></td><td>Color $color</td><td>PDF needed $pdf</td><td>Website update needed $web</td></tr> <tr><td ></td><td>Estimated print quanity $quanity</td><td></td><td></td></tr> <tr> <td colspan=\"4\" align=\"left\" valign=\"top\"><hr height=\"5\"/> <strong><font size=\"+1\">Graphics office use only</font></strong></td> </tr> <tr> <td height=\"25\" width=\"2%\"> </td> <td width=\"34%\">Print Shop Color copier</td> <td colspan=\"2\">Print Vendor_______________________________________</td> </tr> <tr> <td height=\"25\"> </td> <td><strong><font size=\"+1\">Project tracking</font></strong></td> <td> </td> <td> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Received by graphic designer_______________________ Date _______</td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\"> <table width=\"100%\" height=\"35\"> <tr> <td>Approved by executive director__________ Date_________</td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td><tr> </table> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Completed and spell checked by graphic designer___________________________ Date__________</td> </tr> <tr> <td> </td> <td align=\"center\" colspan=\"3\"> <table cellpadding=\"10px\" cellspacing=\"0\" border=\"1\" width=\"100%\"> <tr bgcolor=\"#CCCCCC\"> <td> <table> <tr> <td> Proofread by marketing coordinator __________ Date__________</td> </tr> <tr> <td> Proofread by secretary __________ Date__________ </td> </tr> </table> </td> <td> <input type=\"checkbox\"> Revisions needed <br> <input type=\"checkbox\"> Revisions made ____ Date_____ </td> </tr> </table></td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td>Proofread by executive director______ Date______ </td><td><input type=\"checkbox\"> Revisions needed<br /> <input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td> Approval by requesting department __________ Date_________ <br /> <strong><font size=\"-1\">(Include all paperwork when returning)</font></strong></td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <td></td height=\"25\"> <td colspan=\"3\">Final approval by executive director _________________________________________ Date_________ </td> </tr> <tr> <td height=\"75\"></td> <td><input type=\"checkbox\"> Printed ____ Date _____</td> <td colspan=\"2\"><input type=\"checkbox\"> PDF created _____ Date _____<br /> <input type=\"checkbox\"> Website updated _____ Date _____</td> </tr> </table>"; $message .= "</body></html>"; mail($email, $subject, $message, $headers, "From: $email"); echo "The email has been sent."; ?> $to=sammieave@ave.com,samuel@ave.com; $subject = "New Event Logged"; $message = "Test"; $headers = "From: Samuel<sammieave@ave.com>;\r\n"; $headers .= "Content-Type: text/html"; mail($to,$subject,$message,$headers); I am having the above code but unfortunately the error I am getting is: Warning: mail() [function.mail]: SMTP server response: 550 Requested action not taken: mailbox unavailable or not local in C:\xampp\htdocs\CRM\support\mailer.php on line 139 I am using magento for sending mail with condition, My code: <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('abc@gmail.com'); $emailTemplate->send(); } } ?>
Output :
If order placed mail send to abc@gmail.com. I want :
1) If SKU starts with 2, email should go to the mail id abc@gmail.com,
2) If SKU starts with 3, email should go to the mail id xyz@gmail.com,
3) If SKU starts with 4, email should go to the mail id qwe@gmail.com,
FYI - If an order contains 10 items email should go separately based on SKU. But an order id the same must include all the emails.
Hello there, I've come across a issue with using PHP's mail function due to the fact I've tried a assortment of different headers yet Hotmail continues to place my sent emails in the junk folder. Here is my method of emailing my clients: function Email($AccountID, $Subject, $Message) { if($this->IsValidAccount($AccountID)) { $Account = $this->AccountKeys($AccountID); $headers .= 'To: '.$Account['account_client'].' <'.$Account['account_email'].'>' . "\r\n"; $headers .= "From: X-Host <no-reply@X-Host.co.uk>\r\n"; $headers .= "Reply-To: X-Host <no-reply@X-Host.co.uk>\r\n"; $headers .= "Return-Path: no-reply@X-Host.co.uk\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= "Organization: X-Host\r\n"; echo $Account['account_email']. $Subject. $Message; return mail($Account['account_email'], $Subject, $Message, $headers); } else return InvalidAccount; } So could anybody help me out please and tell me what headers I should be using. Hi all, I'm coding an automated mailer for a dentist office. They set appointment dates through a web interface, and then this appointment is mailed to the customer via PHP's mail() function. However, some users are not receving the mail. They claim that it is not even in the junk mail folder. Is it because I'm setting or not setting certain properties in the header? Should I be setting something else? Here is my code Code: [Select] ini_set("SMTP", "mail.isp-provider.net"); $headers = 'From: Schedule Manager <schedule@address.com>' . "\r\n" . 'Reply-To: Schedule Manager <schedule@address.com>' . "\r\n" . 'Bcc: internal@address.com' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($customerAddress, $subject, $body, $headers); Note that customerAddress, subject, and body are all just regular normal strings. As I said, it works for most customers, but some customers do not receive the emails. Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hello Guys,
I need your help as many PHPers here is more experienced in PHP coding than me. I have specific project I am working on and need a piece of code that can send an email from HTML form using PHP to the email address that is entered manually on the form, instead of standard sent to PHP code that is fixed within PHP script and executed during submission. I want sth that can grab manually enetered recipient's e-mail address, paste it to the PHP code and then use it to send the email to the recipient, instead of fixed sent to code. Something would say dynamically changed during the entry that can inject into PHP code the new address email entered on the form and then submit to it. Any ideas will be great.
Thanks.
Edited March 27, 2019 by slawotrend Hi guys, I have a problem with the $header variable. I am trying to extract the value from the $name method and included with the $email method. <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myusername'); define('DB_PASSWORD', 'mypass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $name = clean($_GET['name']); $email = clean($_GET['email']); $type = clean($_GET['type']); $comments = clean($_GET['comments']); if($name == ''){ $errmsg_arr[] = 'name are missing.'; $errflag = true; } elseif($email == ''){ $errmsg_arr[] = 'email are missing.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['name'])) { $insert[] = 'name = \'' . clean($_GET['name']) .'\''; } if(isset($_GET['email'])) { $insert[] = 'email = \'' . clean($_GET['email']) . '\''; } if(isset($_GET['type'])) { $insert[] = 'type = \'' . clean($_GET['type']) . '\''; } if(isset($_GET['comments'])) { $insert[] = 'comments = \'' . clean($_GET['comments']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($email)){ $name = $_GET['name']; $email = $_GET['email']; $header = 'From: $name <-f $email>' . "\r\n"; $to = "myname@myemail.com"; $subject = $type; $message = "$comments"; $header .= "MIME-Version: 1.0\l\n"; mail($to, $subject, $message, $header); echo "Thank you for sent us your email"; } } } ?> Something got to do with this line: $header = 'From: $name <-f $email>' . "\r\n"; My problem is I can see in my email that the sender name has been included with (unknown sender) while the email address are display as empty address. I am really not sure why I have got the blank sender name and with the blank sender address. Do you know what the main problem is and what I need to change it with? Any advice would be much appreciate. Thanks, Mark Hey folks, I made a small shopping cart but I struggle with receiving an email with the orders; thanks in advance this is the mail.php <?php session_start(); if($_POST['sendemail'] == 'Email') { $headers = 'From: Sender <andrej13@gmail.com>'; mail('andrej13@gmail.com', 'Subject', $_SESSION["cart"], $headers); echo "DEBdsUG".$_POST["cart"]; echo 'Your mail has been sent'; } else { echo 'Your mail was not sent'; } ?> this is the cart.php <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo &#0183; Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> <form action="mail.php" method="post"> <input type="submit" name="sendemail" value="Email" /> <input type="hidden" name="cart" value="<?= $cart; ?>" /> </form> </div> </body> </html> Hello Im making html mail for my project. However the mail() function of PHP does not send my email. Code: [Select] <?php $message = ' <html> <head> <title>Test Email</title> </head> <body> <h4>This is a test email message from me</h4> <br/> <p><b>Lorem Ipsum<b><br/> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> </body> </html> '; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'To: me <darkstarnexus@yahoo.com>' . "\r\n"; $headers .= 'From: Sample <sample@mail.com>' . "\r\n"; $headers .= 'Cc: Sample2 <sample2@mail>' . "\r\n"; $headers .= 'Bcc: sample3@mail' . "\r\n"; if(mail('darkstarnexus@yahoo.com', 'Test Html Email', $message, $headers)){ echo "mail delivered"; }else{echo "mail is not delivered";} ?> Can some tell me why? Hi Everyone, I am trying to send email with the mail() function as per instructions at: http://php.net/manual/en/function.mail.php without success. The mail sends but when it arrives it doesn't render properly, I see all of the html tags with the data that's sent. My code is below: Code: [Select] <?php function processFormData($array, $form) { $errors = NULL; $message = NULL; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = "From: <chuck@deneb-consulting.com>" . "\r\n"; $headers .="Cc: <tinwakr@bell.net>" . "\r\n"; $headers .= "Reply-to: <chuck@deneb-consulting.com>" . "\r\n"; $headers .= "X-Mailer: PHP/" .phpversion() . "\r\n"; foreach($array as $key => $value) { //if any of the form values are empty catch them and add to error array if(empty($value) && $key != 'submit') { //build error list $errors .= '"' . str_replace('_', ' ', $key) . '" is a required field!<br />'; } else if(!empty($value) && $key != 'submit') { //capture values and insert them into a session variable $_SESSION[$key] = $value; } } if(empty($errors)) { $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\r\n"; $message .= '<html><head><title>' . $form .'</title></head>' . "\r\n" . '<body><table border="1">' . "\r\n"; foreach($array as $key => $value) { //regular expression check for phone number if(str_replace('_', ' ', $key) == 'Phone Number' && !preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $value)) { return 'Please enter a valid phone number!'; } //regular expression check for email if(str_replace('_', ' ', $key) == 'Email Address' && !preg_match("/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i", $value)) { return 'Please enter a valid email address!'; } if($key != 'submit') { $message .= '<tr><td>' . $key . '</td><td>' . $value . '</td></tr>' . "\r\n"; } } $message .= '</table></body></html>' . "\r\n"; mail("chuck@deneb-consulting.com", $form, str_replace("_", " ", $message), $headers); return 'Thank you, someone will contact you shortly.'; } else { return $errors; } } ?> Thanks in advance for all replies, Chuck Hi, I'm pretty new to PHP and I am working on a form that sends and email. I want to display a message if the mail can't be sent (i.e. if mail() returns false) and a different message if mail() returns true, except it is returning false even though the emails are sending. Basically I have used: $to = 'myemail@email.com'; $subject = "Subject Line Goes here"; $headers = "From: $email"; $message = 'My message'; $mailSent = mail($to, $subject, $message, $headers); In testing it I have used the following to determine what is going on: if (isset($mailSent)) { echo '$mailSent ='.$mailSent; } - echo's nothing if ($mailSent == FALSE) { echo '$mailSent = FALSE'; } - echo's '$mailSent = FALSE' if ($mailSent == TRUE) { echo '$mailSent = TRUE'; } - echo's nothing if (is_null($mailSent)) { echo '$mailSent = NULL'; } - echo's '$mailSent = NULL' echo '$mailSent ='.$mailSent; - echo's '$mailSent =' Any help would be greatly appreciated! Thanks! Okay, below is my mailer for a contact form i created. On one site it works fine. I even have it sending to several addresses from the othersite. However this site it doesnt want to work. PHP5 and mail() function is active. <?php $Name = Trim(stripslashes($_POST['fullname'])); $EmailFrom = Trim(stripslashes($_POST['email'])); $EmailTo = "james@jd-creations.co.uk"; $Subject = Trim(stripslashes($_POST['subject'])); $answer = Trim(stripslashes($_POST['answer'])); $Comments = Trim(stripslashes($_POST['message'])); $Subject = "The Reason - Contact Us"; // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($answer)!=="20") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Comments)=="") $validationOK=false; if (Trim($Subject)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error2.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/sent.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error.php\">"; } ?> now i know it is wroking because it takes me to the sent.php page. not error.php i think it worked once. now not at all. When I test my php, all of the errors work, but when I actually want to send an email the form doesnt go through and I get the error message 'Please enter a valid e-mail address'? I think I may have something wrong in my mail function. Code: [Select] <?php if (empty($_POST['author'])) { $errors[] = 'Please enter a name'; } if (empty($_POST['subject'])) { $errors[] = 'Please enter a subject'; } if (empty($_POST['text'])) { $errors[] = 'Please enter your comments.'; } if (empty($_POST['email'])) { $errors[] = 'Please enter an e-mail'; } else if (!preg_match("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$ ^", $_POST['email'])) { $errors[] = 'Please enter a valid e-mail address'; } if (count($errors) == 0) { // Process form mail("solysol05@gmail.com","Subject: subject", text,"From: author <email>"); echo "Thank you for using our mail form.<br/>"; echo "Your email has been sent."; } else { echo $errors[0]; } ?> Say I have an email info@website.com created in cPanel on a web hosting company. I want to send email notifications to users on my website. I am using PHP Mailer to send the emails. But all the emails go directly into their junk box/spam folder, unless they confirm that info@website.com is not junk. I am wondering if there is a work around for this? Hello, I have some troubles to send mass email. I am using mail() function and the script is timed out. also there is a restriction in which you allowed to send 20 mails per minute. so I use sleep(5) to delay 5 seconds between every mail, but the script is exceeded timeout. Adding this: set_time_limit(0); will still not work. maybe can I set a background thread? if so please tell me how to. Also, if there is a built in script that can help me with that, I would like to hear about it. Thanks =] function isValidEmail($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } How do I incorporate the code above into my code?? Code: [Select] <?php error_reporting(E_ALL ^ E_NOTICE); ?> <?php // make sure the form has actually been submitted . . . if( strtolower($_SERVER['REQUEST_METHOD']) === 'post' ) { // 1. Create a database connection $connection = mysql_connect("localhost", "root", "maven777"); if(!$connection){ die("Database connection failed: " .mysql_error()); } // 2. Select a database to use $db_select = mysql_select_db("homesloans", $connection); if(!$db_select){ die("Database selection failed: " .mysql_error()); } $radius = ($_POST['radius']); $type = ($_POST['type']); $price = ($_POST['price']); $bedrooms = ($_POST['bedrooms']); $bathrooms = ($_POST['bathrooms']); $parking = ($_POST['parking']); $city = ($_POST['city']); $details = ($_POST['details']); $firstname = ($_POST['firstname']); $lastname = ($_POST['lastname']); $email = ($_POST['email']); $phone = ($_POST['phone']); $query="INSERT INTO leads (leadid, city, radius, type, price, bedrooms, bathrooms, parking, details, firstname, lastname, email, phone) VALUES('NULL', '[$city]', '[$radius]', '[$type]', '[$price]', '[$bedrooms]', '[$bathrooms]', '[$parking]', '[$details]', '[$firstname]', '[$lastname]', '[$email]', '[$phone]')"; mysql_query($query) or die ('Error updating database'); echo "Database Successfully Updated."; // not necessarily. The only way to know for sure is to check that mysql_affected_rows() > 0 } ?> I apologize if I am in the wrong forum so I hope somebody can help. I have a function which sends an emails to client everytime an order is processed. They have asked me to add a print button in the emails so they could just print the email. I have tried using javascript and call the window.print function but when I click the button nothing happens. I know that it is possible to add a print button in an email but I can't figure out what I am doing wrong. Here is some of the code use to create the email using paypal ipn script. Code: [Select] $body = "<html>". "<head>". "<script type='text/javascript'>". "//<![CDATA[ function PrintEmail(){ window.print(); } //]]> ". "</script>". "</head>". "<body>". "<a href='javascript:window.print()'>Print Page</a><br />". "<input type='button' onclick='javascript:PrintEmail();' value='Print This Page' /><br /><b>Customer Name</b>: ".$name."<br />"; foreach($id_str_array as $key => $value){ $id_quantity_pair = explode(":", $value); $product_id = $id_quantity_pair[0]; // Get the product ID $cameo_color = $id_quantity_pair[1]; $product_quantity = $id_quantity_pair[2]; // Get the quantity $product_line1 = $id_quantity_pair[3]; // Get Line 1 $product_line2 = $id_quantity_pair[4]; // Get Line 2 $product_picture = $id_quantity_pair[5]; // Get picture $discount_code = $id_quantity_pair[6]; $body .= "<b>Product</b>: ".$product_id."<br />". "<b>Quantity</b>: ".$product_quantity."<br />". "<b>Engraving Line 1</b>: ".$product_line1."<br />". "<b>Engraving Line 2</b>: ".$product_line2."<br />". "<b>Your picture</b>: <img src='http://t3.sysguru.com/mcf/pictures/".$product_picture."' height='300' width='556' /><br />"; } $body .= "<b>Total</b>: $".$_POST['mc_gross']."</body></html>"; $subject = "Transaction Completed"; $mailer->SendPayPalInfo($subject, $body); I tried just calling the javascript print function with a link and aslo create a function and called the function from the button and neither of these methods work. here is the code which send the message out. Code: [Select] function SendPayPalInfo($subject, $body){ $headers = "From: " .EMAIL_FROM_ADDR. "\r\n"; $headers .= "Reply-To: ".EMAIL_FROM_ADDR."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; return mail(EMAIL_FROM_ADDR, $subject, $body, $headers); } Am I missing something in the headers of am I coding this wrong? Any help would be appreciated. |