PHP - Mail() Function Not Working In Php
Hello,
The mail function works on my one website but it won't on my other site. On the site that it won't work on, I'm trying to email the contents of the cart. I tested it out and it diplays the contents of the cart properly if I echo $email. I don't get any errors on the site, it seems to process but I don't receive any emails. here is my code for process.php: Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','1'); require_once("connect.php"); ?> <?php $check=$_POST['check']; /* code that outputs the cart contents and totals up the cart */ $cartOutput=""; $total="0"; // start the foreach loop to go through each item in the cart array $i=0; foreach($_SESSION["cart_array"] as $each_item) { $item_id=$each_item['id']; $prod_id=$each_item['product_id']; // distiguish between a regular item and a gift box switch ($prod_id) { // if it is a gift box case "12": // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic checkout button assembly // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40% valign=center><font face=arial color='#999999'>Wrap my products in a Gift Box</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']." </td> <td width=5%><font color='#999999'>$".$price.".00</font></td> <td width=10%><font color='#999999'>$".$subtotal.".00</font></td> </tr> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is a Reed Diffuser Bottle case "17": // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName, products.productDesc FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; $desc=$row['productDesc']; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic checkout button assembly // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40% valign=center><font face=arial color='#999999'>".$desc."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']."</td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is a salve case "3": $salveId=substr($each_item['id'],2,4); $prodId=substr($each_item['id'],0,1); // Get product name and price $sql=mysql_query("SELECT * FROM salves WHERE productId='$salveId' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $scent=$row['productName']; } $sql=mysql_query("SELECT * FROM products WHERE productId='$prodId' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $price=$row['productPrice']; $product_name=$row['productName']; } if(isset ($_SESSION["cart_array"] )) { $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".$each_item['id']."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40%><font face=arial color='#999999'>".$scent."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']." </td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr></form> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is not a gift box or sale/clearance item default : $scent=substr($each_item['scent'],0,4); // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; } // get scent for regular product $sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent' LIMIT 1"); while ($row2=mysql_fetch_array($sql2)) { $scent=$row2['scentName']; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40%><font face=arial color='#999999'>".$scent."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']."</td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr></form> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; } // end switch } // end foreach that goes through each item in the cart /* Code that generates the email */ $ans=$_SESSION['check']; $check=$_POST['check']; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // customer information $firstName = strip_tags($_POST['firstName']); $lastName = strip_tags($_POST['lastName']); $address = strip_tags($_POST['address']); $city = strip_tags($_POST['city']); $prov = strip_tags($_POST['prov']); $postalCode = strip_tags(strtoupper($_POST['postal'])); $emailAddress = strip_tags($_POST['email']); $payment = $_POST['payment']; $ship = $_POST['shipping']; // email subject $subject= "Online Order Request"; // email address the form will be submitted to $myemail="orders@coppercreekbathandbody.ca"; if ($firstName!="" && $lastName!="" && $address!="" && $city!="" && $prov!="" && $postalCode!="" && $emailAddress!="" && $ans==$check) { $email="<html><center> <table border=0 width=100% cellspacing=0 cellpadding=5 style='background:#1d1d1d' > <tr> <td colspan=6><center><h2><font color=#999999>$subject</font></h2></center></td> </tr> <tr valign=center > <td colspan=6 align=center valign=center><font face=arial color=#999999> $firstName $lastName<br> $address<br> $city, $prov $postalCode<br> $emailAddress </font><br><br> </td> </tr> <tr align=center style='background: #333'> <td width=8%><font face=arial color=#999999>Item #</font></td> <td width=25%><font face=arial color=#999999>Product</font></td> <td width=40%><font face=arial color=#999999>Description</font></td> <td width=4%><font face=arial color=#999999>Quantity</font></td> <td width=4%><font face=arial color=#999999>Price</font></td> <td width=10%><font face=arial color=#999999>Total Cost</font></td> </tr> <tr><font face=arial> $cartOutput </font></tr> <tr style='background: #333'> <td colspan=5 align=right><font face=arial color=#999999>Total Price:</font></td> <td align=center><font face=arial color=#999999>$".$total.".00 </font></td> </tr> <tr> <td colspan=4 align=right valign=center> <font face=arial color=#999999>Payment Method: </font> </td> <td colspan=2 align=right valign=center> <font face=arial color=#999999>$payment</font> </td> </tr> <tr> <td colspan=4 align=right valign=center> <font face=arial color=#999999>Shipping: </font> </td> <td colspan=2 align=right valign=center> <font face=arial color=#999999>$ship</font> </td> </tr> </table></center></body></html>"; mail($myemail, $subject, $email, $headers); unset($_SESSION['check']); header("location: success.php"); } else { unset($_SESSION['check']); } customerInformation.php Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','1'); require_once("connect.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text/javascript" src="./js/functions.js"></script> <link rel="stylesheet" type="text/css" href="./css/navigationStyles.css"/> <script language=javascript type=text/javascript> function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if ((evt.keyCode == 13) && (node.type=="text")) { return false; } } document.onkeypress = stopRKey; </script> </head> <body> <div id='wrapper'> <div id='main'> <table border=0 width=70% cellspacing=10 cellpadding=5 id=table> <tr> <td colspan=6> <center><img src="./images/customerInfoLogo.gif"><br> <table border=0 width=90%> <tr> <td width=33% align=right> <a href='index.php'>HOME</a> </td> <td width=34%></td> <td width=33% align=left> <a href='cart.php'>VIEW CART</a> </td> </tr> </table> <br><br> </center> </td> </tr> <tr> <td colspan=6 align=center valign=center> <form action="process.php" name='order' method="post" onsubmit="document.getElementById('button').disabled=true; document.getElementById('button').value='Submitting, please wait...';"> <!-- REQUEST ORDER TABLE --> <table width=90% border=0 cellspacing=5 cellpadding=5> <!-- CLIENT NAME --> <tr valign=center> <td width=50% align=right> First Name: </td> <td width=50% align=left> <input type=text maxlength=40 width=40px class=contactBox id=firstName name="firstName" onBlur="validate(this.id);"> </td> </tr> <tr valign=center> <td width=50% align=right> Last Name: </td> <td width=50% align=left> <input type=text maxlength=40 width=40px onBlur='validate(this.id);' class=contactBox id=lastName name="lastName"> </td> </tr> <!-- ADDRESS --> <tr valign=center> <td width=50% align=right> Address: </td> <td width=50% align=left> <input type=text width=40px id=address class=contactBox name="address" onBlur='validate(this.id);'> </td> </tr> <!-- CITY --> <tr valign=center> <td width=50% align=right> City: </td> <td width=50% align=left> <input type=text width=40px id=city class=contactBox name="city" onBlur='validate(this.id);'> </td> </tr> <!-- Province --> <tr valign=center> <td width=50% align=right> Province: </td> <td width=50% align=left> <select name="prov"> <option value="AB">Alberta</option> <option value="BC">British Columbia</option> <option value="MB">Manitoba</option> <option value="NB">New Brunswick</option> <option value="NL">Newfoundland & Labrador</option> <option value="NT">Northwest Territories</option> <option value="NS">Nova Scotia</option> <option value="NU">Nunavut</option> <option value="ON">Ontario</option> <option value="PE">Prince Edward Island</option> <option value="QC">Quebec</option> <option value="SK" selected>Saskatchewan</option> <option value="YT">Yukon</option> </select> </td> </tr> <!-- POSTAL CODE --> <tr valign=center> <td width=50% align=right> Postal Code: </td> <td width=50% align=left> <input type=text width=40px id=postal class=contactBox name="postal" maxlength=7'> </td> </tr> <!-- EMAIL ADDRESS --> <tr valign=center> <td width=50% align=right> Email: </td> <td width=50% align=left> <input type=text width=60px id=email class=contactBox name="email" onBlur='validateEmail(this.id);'> </td> </tr> <!-- PAYMENT TYPE --> <tr valign=center> <td width=50% align=right> Payment Type: </td> <td width=50% align=left> <select name="payment"> <option value="Email Money Transfer" selected>Email Money Transfer</option> <option value="Cash">Cash</option> <option value="Money Order">Money Order</option> </select> </td> </tr> <!-- SHIPPING --> <tr valign=center> <td width=50% align=right> Need your order shipped: </td> <td width=50% align=left> <select name="shipping"> <option value="Don't Ship" selected>Don't Ship</option> <option value="Ship Order">Ship Order</option> </select> </td> </tr> <tr> <td colspan=2> <img src='captcha.php'> <input type='text' class=cap size=4 width=3 maxlength=4 onKeyPress='return check_qty(event);' name='check'> </td> </tr> <tr> <td colspan=2 valign=top> <input type=submit value='SEND ORDER' class='updateButton' id=button> <input type=reset value='CANCEL ORDER' class='updateButton' id=button onClick="location.href='home.php'"> </td> </tr> </table> </form> </td> </tr> </table> </div> <div id="sidebar" > <?php require ("menu.html"); ?> </div> </div> </body> </html> I have no idea what is happening. It should be displaying an html formatted email. Any help is greatly appreciated. Similar TutorialsWhenever try to use the PHP mail function on my local server it also fails but then when I upload my scripts to my webspace they work fine. I think there must be something wrong with my php.ini file. Below I have copied the mail function section of my php.ini file. [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = sendmail -t -i ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = Thanks for any help. Hello Everyone, I do not know if I am not doing something right or if I am completely wrong. I am trying to get an error or success message depending on the out come . This is the code that I have written so far Code: [Select] <?php if (!$_POST['submit']){ $msg = "you must enter a name and message"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } else { $name = $_POST['name']; $message = $_POST['message']; if (strlen($name) <= 20 && $message <= 300){ if (($name == "") || ($message == "")){ $msg = " please fill in all required feilds"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } else { ini_set("SMTP", "smtp.greatlakes.net"); $to = "mikedmartiny@gmail.com"; $subject = "Classified Ad Submission"; $headers = "From: autostylersrv@greatlakes.net"; $headers = "MIME-Version: 1.0rn"; $headers = "Content-type: text/html"; $headers = "charset=iso-8859-1rn"; $message = "<html><body>This is a email sent from $name<br /><br />$message</body></html>"; function mail($to, $subject, $message, $headers) { $msg = "mail has been sent"; } else { $msg = "there was a error"; } } } else { $msg = "You have exceded the max lentgh"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } } echo "$msg"; ?> Hi
I wrote some basic custom php code that presents a form to a user, they submit their details and an email gets sent to me.
I checked and the fields from the form are being carried over.
Up to about a week ago it was working and now it has stopped working and I have no idea why.
I have checked with my isp and no changes were made to anything
php version is 5.2
Attached Files
php-ini.txt 1.07KB
1 downloads
contact-process.php 3.3KB
3 downloads Hi people, please can some one help me out with a bit of php for the 'mail function'? All i want to do is have the end user fill out the form, hit submit then either have the user directed to a thank you page or have pop up message stating that the information has been sent. At the moment the code i have does not seem to be sending the mail and aditionally i have no idea where or how to start writing the code for the thank you page or the conformation pop up message. Please can some one show me the light on this one, i am really just starting out with php and finding it real hard. Anyway guys this is the code i have, please let us know what i'm doing wrong and what i need to add to it. Code: [Select] <?php if(isset($_POST['submit'])) { $to = "my_email@mydomain"; $subject = "Contact Form"; $name = $_POST['name']; $comp_name = $_POST['company_name']; $email = $_POST['email']; $phone = $_POST['contact_number']; $location = $_POST['location']; $message = $_POST['message']; $body = "From: $name\n E-Mail: $email\n Company Name: $comp_name\n Contact Number: $phone:\n Location: $location:\n Message:\n $message"; mail($to, $subject, $body); } ?> Hope some one can help, many thanks in advance. Cheers. 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.
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 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. I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); how do i alter this code so that the recipients don't see other email addresses ? <?php
foreach(array('email1','email2','email3','youremail','yourname') as $key) $_POST[$key] = strip_tags($_POST[$key]);
# This part submits a notification to you when
// Email address for copies to be sent to - change to suit
// Notification email subject text for copies
// Email body text for notifications The people the recommendation has been submitted to a
$_POST[email1] The page recommended: $_POST[refurl] "; # This function sends the email to you @mail("$emailto", $esubject, $emailtext, "From: $_POST[youremail]"); # This part is the function for sending to recipients
// Page to display after successful submission $thankyoupage = "thankyou.html"; // Subject line for the recommendation - change to suit $tsubject = "A web page recommendation from $_POST[yourname]";
// Change the text below for the email
$ttext = " $_POST[yourname], whose email address is $_POST[youremail] thought you may be interested in this web page. $_POST[refurl] $_POST[yourname] has used our Tell-a-Friend form to send you this note. We look forward to your visit! ";
# This sends the note to the addresses submitted
# After submission, the thank you page } # Nothing further can be changed. Leave the below as is
function is_secure($ar) {
function array_values_recursive($array) { ?> I'm using the php mail function on some forms for our company website. There is reason to believe that they sometimes don't work. Is this a normal behavior for this? We've been "discussing" whether or not they work for about 2 - 3 days and in most instances they do. However we've had 1 person fill them out and then we never received the emails. I was wondering if some of the people that have worked with php for a longtime have ever had any experience with this type of thing happening. How do I include .$email to the mail function. this is my current code: mail($to, $subject, "", $headers); I want do it like this; mail("me@myweb.com".$email, $subject, "", $headers); Thanks Bickey. Hi, I'm trying to do an email from a website and it won't work. It's my first time using mail function, so I'm not sure why it is not working. Please check my code <?php $name = strip_tags($_POST['name']); $email = $_POST['email']; $qst_id=strip_tags($_POST['qst_id']); //if no ajax $opt =$_POST['opt']; $s_id = $_SERVER['REMOTE_ADDR']; $to = 'test@test.com, test1@test.com'; $subject = 'Someone just voted'; $message = "Someone from the ip address ".$s_id; // 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"; $headers .= 'From: Vote Detector <website@test.com>'. "\r\n"; if ($name!='') { $message = $message." with the name ".$name; } if ($email!='') { $message = $message." with email ".$email; } $message = $message." voted "."yes<br/>"; $message = $message."total number of people who declared their faith: ".$total_count." people<br/>"; $message = $message."with a total of ".$total_opt[0]." people saying yes"; $message = $message." and a total of ".$total_opt[1]." people saying no<br/>"; mail($to, $subject, $message, $headers); ?> Thanks in advancr is there a way to make a mail function submit only once? so that if you go forward a page, then back, it won't resubmit? It just so happens that I have never used the PHP mail() function and i believe i've hit my first major snag. So if any of you brilliant minds out there can just take a second to error check the following code id GREATLY appreciate it! The db is connected earlier and i KNOW all the vars work because the script worked before i stuck in the mail() section. //REVISE else{ $q = mysql_query("INSERT INTO account (Username, Firstname, Lastname, Email, Active, User_type, User_language, User_registration, Pass) VALUES('$username', '$firstname', '$lastname', '$email', '$active', '$type', '$language', '$today', '$password')") or die(mysql_error()); $id = mysql_query("SELECT id FROM account WHERE Username = '$username'"); $message = "Welcome to the exciting world of Star Wars Galaxies : A New Hope! Your new username is ".$username."! Please click the following link or paste it in a web browser to complete the activation process. HTTP://www.swganh.com/account_activate.php?id=".$id;//LANGINSERT $headers = "From: matt@swganh.com.com\r\n"; mail($email, 'SWG:ANH New account registration/confirmaton', $message, $headers);//LANGINSERT } The problem is that im just not getting a mail when i send it to myself... No errors, but no mail either. Thanks in advance guys! how do I make a link to the correct fpdf file that will be created.......I want to know how I can have an email sent, and then I put a link into the email which looks like: <a href="/ticket.php?eventid=' . $eventid . '">Ticket</a>. does this make sense? do I have to save the document on the server to do this? ok, so I have this code and I need to know how to modify it so that the strings display properly............so that it wont display $string but instead whatever value it is.........can you please help: Code: [Select] $to = "$email"; // Change this to your site admin email $from = "events@site.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <style type="text/css"> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id="apDiv1"> <table width="408" border="1" cellspacing="2" cellpadding="2"> <tr> <th width="90" scope="col">Event(s):</th> <th width="298" scope="col"> $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET["eventid"]." LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $subevent1 = $row["subevent1"]; $subevent2 = $row["subevent2"]; $subevent3 = $row["subevent3"]; $subevent4 = $row["subevent4"]; $subevent5 = $row["subevent5"]; $subevent6 = $row["subevent6"]; $subevent7 = $row["subevent7"]; $subevent8 = $row["subevent8"]; //this will echo the contents of each db row as they are iterated in the loop ############################# if (!empty($title1)) { echo "<br/>$title1:"; } if (!empty($title2)) { echo "<br/>$title2:" ; } if (!empty($title3)) { echo "<br/>$title3:"; } if (!empty($title4)) { echo "<br/>$title4:"; } if (!empty($title5)) { echo "<br/>$title5:"; } if (!empty($title6)) { echo "<br/>$title6:"; } if (!empty($title7)) { echo "<br/>$title7:"; } if (!empty($title8)) { echo "<br/>$title8:"; } } //etc etc </th> </tr> <tr> <th>Price:</th> <th> $total = $price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8 ; echo $total; </th> </tr> <tr> <th>Registrant:</th> <th><?php echo $name; ?></th> </tr> </table> </div> <div id="apDiv2"><?php echo $name; ?> <p> </p> <p> </p> <p><a href="index.php" target="_new"><strong>Troop 78 Home</strong></a></p> <p> </p> <p> </p> <p><strong><"></a></strong></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <img name="boyscout" src="button/boyscout.jpg" width="1180" height="700" border="0" id="boyscout" alt="" /> </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; $to = "@gmail.com"; // Change this to your site admin email $from = "events@site.net"; $subject = "New Registration for $event"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body> Hello, Aaron $name has registered for $event. they will owe $total = $price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8 ; echo $total; </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; Hello, I am using php to send verification links for my website.The registration form sends data to xyz.php(using AJAX) and the response(echo'd part of xyz.php) is returned and shown to the user. The problem i am facing is that the function "$mail->Send()" is echoing the smtp server response.How can i stop this function from echo'in anything. Please reply asap. |