PHP - Send Confirmation Email Problems
I still have little knowledge of php, I asked a question earlier but that gave me so as it is now my help please.
I'm looking for an easy script that sends the info and send a confirmation. but everyone says something different. Have you a script that I only need to change what data? before hand thanks now use this script but does not work also completely leak, I understood for spammmers Similar TutorialsHi, I'm new here and new to php. My first attempt at a php project actually so I'm hoping to get some help. I want people to register at my site but I don't want them to put false emails on it. So I used the coding from this website http://www.phpeasystep.com/workshopview.php?id=24 to provide codings for forms and email confirmation links. The process worked up to when I click on the confirmation link (at testing) from the email and the link returns to a blank webpage. No data is transferred from "temp_members_db" table to "registered_members" table at all. I'll attach print screen of my tables. Hoping that someone can point out to me where I'm going wrong as I can't seem to get myself out of this one. Hello, When a user sends a message using my contact form, they will get a confirmation to the supplied email to confirm that the email has been recieved, one problem is, the auto-reply message displays "donotreply@website.com" at the bottom of it, here is some of my code: //AUTO-REPLY CLIENT CODE START $confirmation = $visitor_email; $consubject="Your message has been recieved"; $body2 = "Hello $name, \nThe below message has now been recieved.\n\n >> $user_message <<\n\nWe will reply to you shortly.\n\nThank you,\n\nThe website Team.\n\n\nThis is an automated message, please do not reply to it.\n". $fromnoreply = 'donotreply@website.com'; //AUTO-REPLY CLIENT CODE END //TO WEBMAIL CODE START $to = $your_email; $subject="Contact form - $name"; $from = $visitor_email; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Name: $name\n". "Email: $visitor_email \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; //TO WEBMAIL CODE END //headers $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; $headers2 = "From: $fromnoreply \r\n"; $headers2 .= ""; // the important stuff!, yes definately! JAMES mail($to, $subject, $body,$headers); mail($confirmation, $consubject, $body2,$headers2); header('Location: ?sent'); //where shall i go once message is sent?? Possibly here. *wink* The above code automatically sends the below email to the client aswell as sending the clients message to me. Code: [Select] Hello Bob Smith, The below message has now been recieved. >> This is a test << We will reply to you shortly. Thank you, The website Team. This is an automated message, please do not reply to it. donotreply@website.com My objective is to remove the displayed email at the bottom of the message. Many thanks I want to send confirmation email to 2 different email boxes. this is the code sending to one box: { $this->load->library('email'); //$config['mailtype'] = 'html'; //$this->email->initialize($config); $this->email->from('no-reply@mymail.com 'Site team'); $this->email->to($em); $this->email->subject('Welcome'); $msg = 'You have registered'; $this->email->message($msg); $this->email->send(); } thanks and what should be the code sending same email to one more email box (example: mymail@gmail. com) I'm trying to incorporate a confirmation email function into an existing php script. I have a form that works perfectly, but I can't figure out how to get it to send an email confirmation. Here's the code ... sorry for posting so much of it, but in case I miss anything ... here it is. It's hosted on GoDaddy on a Linux platform ... if that makes any difference. If anyone can enlighten me ... Please Do. Thanks! <?php $d = date("m-d-y H:i:s"); // assign incomming data $CustomerStatus = $_POST["CustomerStatus"]; $Contact = $_POST["Contact"]; $Name = $_POST["Name"]; $an = str_replace(" ", "", $Name); $Company = $_POST["Company"]; $Address = $_POST["Address"]; //$office = $_POST["office"]; $CityStateZip = $_POST["CityStateZip"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $ResponseType = $_POST["ResponseType"]; $Artwork = $_POST["Artwork"]; $ProjectName = $_POST["ProjectName"]; $DueDate = $_POST["DueDate"]; $EstimateNumber = $_POST["EstimateNumber"]; $PONumber = $_POST["PONumber"]; $Pages = $_POST["Pages"]; $Quantity = $_POST["Quantity"]; $ColorFrontBack = $_POST["ColorFrontBack"]; $FlatSize = $_POST["FlatSize"]; $FoldedSize = $_POST["FoldedSize"]; $StockText = $_POST["StockText"]; $StockCover = $_POST["StockCover"]; $LabelStock = $_POST["LabelStock"]; $Coating = $_POST["Coating"]; $Bindery = $_POST["Bindery"]; $Additional = $_POST["Additional"]; $group1 = $_POST["group1"]; $group2 = $_POST["group2"]; $group3 = $_POST["group3"]; $redirect = $_POST["redirect"]; //$subject = $_POST["Subject"]; /* ************* Begin Configuration ************* */ $relocate = "http://www.xxxxx.com/"; // insert your relocation url here $home = "http://www.xxxxx.com/"; $MOVE_TO_PATH = '/home/content/xxxxx/html/FileUpload/'; $PATH_TO_DIR = 'http://www.xxxxx.com/FileUpload/'; // The following values are used to verify_uploaded_file() as the sizes and types that can be uploaded. $UPLOAD_TYPES['PSD'] = 1; // Allow .psd files $UPLOAD_TYPES['JPG'] = 1; // Allow .jpg files (definition must be upper case) $UPLOAD_TYPES['JPEG'] = 1; // Allow .jpeg files $UPLOAD_TYPES['AI'] = 1; // Allow .ai files $UPLOAD_TYPES['EPS'] = 1; // Allow .eps files $UPLOAD_TYPES['PDF'] = 1; // Allow .pdf files $UPLOAD_TYPES['GIF'] = 1; // Allow .gif files $UPLOAD_TYPES['PNG'] = 1; // Allow .png files $UPLOAD_TYPES['DOC'] = 1; // Allow .doc files $UPLOAD_TYPES['XLS'] = 1; // Allow .xls files $UPLOAD_TYPES['ZIP'] = 1; // Allow .zip files $UPLOAD_TYPES['SIT'] = 1; // Allow .sit files $UPLOAD_TYPES['FLA'] = 1; // Allow .fla files $UPLOAD_SIZES['max'] = 180000000; // Maximum size -- Make sure the file is under 180 MB : 180,000,000 = 180 MB $UPLOAD_SIZES['min'] = 0; // Minimum size -- Arbitrary small file size to distinguish between no file and file submission $sender_name = "Order"; $sender_email = "me@xxxxx.com"; $mailheaders = "Content-Type: text/plain; charset=us-ascii\nFrom: $sender_name <$sender_email>\nReply-To: <$sender_email>\nReturn-Path: <$sender_email>\nX-Mailer: PHP"; //$to = "me@xxxxx.com"; $to = "me@xxxxx.com"; $subject = "Order"; $msg ="$d\n\n"; $msg .= "CustomerStatus: $CustomerStatus\n"; $msg .= "Contact: $Contact\n"; $msg .= "Name: $Name\n"; $msg .= "Company: $Company\n"; $msg .= "Address: $Address\n"; $msg .= "CityStateZip: $CityStateZip\n"; $msg .= "Phone: $Phone\n"; $msg .= "Email: $Email\n"; $msg .= "ResponseType: $ResponseType\n"; $msg .= "Artwork: $Artwork\n"; $msg .= "ProjectName: $ProjectName\n"; $msg .= "DueDate: $DueDate\n"; $msg .= "EstimateNumber: $EstimateNumber\n"; $msg .= "PONumber: $PONumber\n"; $msg .= "Pages: $Pages\n"; $msg .= "Quantity: $Quantity\n"; $msg .= "ColorFrontBack: $ColorFrontBack\n"; $msg .= "FlatSize: $FlatSize\n"; $msg .= "FoldedSize: $FoldedSize\n"; $msg .= "StockText: $StockText\n"; $msg .= "StockCover: $StockCover\n"; $msg .= "LabelStock: $LabelStock\n"; $msg .= "Coating: $Coating\n"; $msg .= "Bindery: $Bindery\n"; $msg .= "Additional: $Additional\n"; $msg .= "group1: $group1\n"; $msg .= "group2: $group2\n"; $msg .= "group3: $group3\n"; $success_block = "<p>Thank you for submitting your information. We will review your information and get back to you within a day or two.</p><br><br>"; /* ************* End Configuration ************* */ I have written a form script that submits the form data to me. This part works fine. I also want to send the sender a confirmation e-mail. I have written this part of the code also, but the from line in the confirmation e-mail is the e-mail of the ISP and not mine. Any suggestions? I have been looking everywhere, and can't find a simple example of scripting a confirmation email. Basically, I have a form that is submitting to a database. But when the user submits the form successfully (I already have the validation in place), it sends their submitted email address a confirmation email. Currently the form submits, fills in fields in a database, and sends the user to a static thank you page. At this time I would like to send them the email. How can this be done somewhat simply? Hello again. I have a site where people can order items, as per this thread : http://www.phpfreaks.com/forums/index.php?topic=345342.0 Now, I would like to be able to send an order confirmation to the person that has made the order, as well as to the site's ordering department. I have this code : Code: [Select] <?php if(isset($_POST['Email'])) { $email_to = "orders@thenewme.co.za"; $email_subject = "The New Me - Order Confirmation"; function died($error) { // error code echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['FName']) || !isset($_POST['LName']) || !isset($_POST['Email']) || !isset($_POST['Phone']) || !isset($_POST['Address']) || !isset($_POST['City']) || !isset($_POST['Pcode'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['FName']; // required $last_name = $_POST['LName']; // required $email_from = $_POST['Email']; // required $telephone = $_POST['Phone']; // not required $address = $_POST['Address']; // required $city = $_POST['City']; // required $postal_code = $_POST['Pcode']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "The New Me - Single Order details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Postal Code: ".clean_string($postal_code)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> This is the whole page's code : Code: [Select] <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>The New Me</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="description" content="An Example of the a flexible, scalable background image." /> <meta name="author" content="Michael Bester" /> <link rel="stylesheet" href="css/flexi-background.css" type="text/css" media="screen" /> <style type="text/css" media="screen"> h1 { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-size: 2em; font-weight: normal; margin-top: 2.5%; margin-bottom: 1em; padding: 0.5em 0; position: absolute; text-align: center; width: 100%; z-index: 2; } h2 { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-size: 1em; z-index: 2; text-align: center; } p { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-weight: normal; z-index: 2; } .copyright { background-color: #fff; background-color: rgba(255,255,255,0.8); color: #333; font-family: Helvetica, Arial, sans-serif; font-weight: normal; font-size: 10px; z-index: 2; } </style> </head> <body> <h1>Welcome to the New Me</h1> <script src="js/flexi-background.js" type="text/javascript" charset="utf-8"></script> <table border="0" cols="3" width="100%"> <tr align="center"> <td><a href="index.htm"><img src="images/Home.gif" alt="Home" id="home" border="0"></a></td><td><a href="products.php"><img src="images/Products.gif" alt="Products" id="prod" border="0"></a></td><td><a href="contact_us.htm"><img src="images/Contact_us.gif" alt="Contact Us" id="contact" border="0"></a></td><td><a href="questions.htm"><img src="images/Questions.gif" alt="Questions?" id="Questions" border="0"></a></td> </tr> </table> <p> </p> <table cols="3" width="100%"> <tr><td width="25%"> </td><td width="50%"><h2>Have you always wanted to lose weight naturally and keep it off?</h2></td><td width="25%"> </td></tr> <tr><td valign="top" align="center"> <img border="0" src="images/gesonde%20kos.jpg" width="129" height="62"><p> <img border="0" src="images/Green%20Tea%201.jpg" width="127" height="92"></p> <p><img border="0" src="images/Picture1.png" width="113" height="265"></td><td><p> <?php if(isset($_POST['Email'])) { $email_to = "orders@thenewme.co.za"; $email_subject = "The New Me - Order Confirmation"; function died($error) { // error code echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['FName']) || !isset($_POST['LName']) || !isset($_POST['Email']) || !isset($_POST['Phone']) || !isset($_POST['Address']) || !isset($_POST['City']) || !isset($_POST['Pcode'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['FName']; // required $last_name = $_POST['LName']; // required $email_from = $_POST['Email']; // required $telephone = $_POST['Phone']; // not required $address = $_POST['Address']; // required $city = $_POST['City']; // required $postal_code = $_POST['Pcode']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "The New Me - Single Order details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Address: ".clean_string($address)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "Postal Code: ".clean_string($postal_code)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> </p></td> <td valign="top" align="left"> <img border="0" src="images/Picture2.png" width="117" height="129"><p> <img border="0" src="images/Picture3.png" width="171" height="91"></p> <p><img border="0" src="images/skaal.jpg" width="111" height="111"></td></tr> <tr><td valign="top" align="center"> </td><td> </td> <td valign="top" align="left"> </td></tr> <tr><td valign="top" align="center"> </td><td> </td> <td valign="top" align="left"> </td></tr> <tr><td valign="top" align="center"> </td><td> <img border="0" src="images/suurlemoen%20sap.jpg" width="124" height="119" align="left"><img border="0" src="images/water.jpg" width="120" height="120" align="right"></td> <td valign="top" align="left"> </td></tr> </table> <p class="copyright"><a href = "http://www.ncc-cla.com">© NCC - vereeniging 2011</a></p> </body> </html> I know I'm probably doing something wrong, can anyone help? Hi guys, I understand that there are websites which do teach about creating Email Confirmation, are there any sites which you can recommend? Thanks Wilson Hi! My question is probably simple but I've been scratching my head for hours now... I'm pretty new to php. I have an online form for orders; when submitted, an email is sent to the shop manager containing the info the client has filled in. So I pass all the info in the code below, but I can't manage to echo the array containing the order's items/qty/item_code. (I'm using Wordpress, Oxygen Builder, Metabox and Code Snippets, if that helps). Here's the code (used as a Code Snippet):
add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
$name = rwmb_meta( 'name', '', $post_id );
Nom: $name
$headers = ['Content-type: text/html', "Reply-To: $email"];
Help with this would be greatly appreciated! Please let me know if any details are missing. Thanks in advance! Jordan Edited June 23 by JordanCHello 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
The code below currently sends a separate Email with data from each row of a table when a Save All button is pressed. So, if I have 4 rows of data, 4 Email will be sent. $email="to@email.com"; $from="from@email.com"; $msg=""; $subject="Registers Info for: ".$values["first_name"]." ".$values["last_name"].""; $msg.= "Student: ".$values["first_name"]." ".$values["last_name"]."\r\n"; $msg.= "Absent or Present: ".$values["attendance_status"]."\r\n"; $msg.= "Class: ".$values["classname"]."\r\n"; $msg.= "Class Date: ".$values["attendance_date"]."\r\n"; $msg.= "Amount Received: ".$values["cash_received"]."\r\n"; $msg.= "Paid For: ".$values["cash_whatfor"]."\r\n"; $ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from)); if(!$ret["Sent"]) echo $ret["message"];
Edited February 27, 2020 by leemo Hi I have a form that I want people to fill out and then click the button and it sends me an email. My problem is that it doesn't send me any emails, I have looked around and I don't seem to find any thing. This is my form in application_form.php Code: [Select] <form action="application_form" method="POST"> <table border="0" cellpadding="5" cellspacing="0"> <tr> <td>Full name</td> <td><input type="text" size="30" maxlength="80" name="name" /></td> </tr> <tr> <td>Email address</td> <td><input type="text" size="30" maxlength="80" name="email" /></td> </tr> <tr> <td>Message</td> <td><textarea name="message" cols="29" rows="5"></textarea></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Submit Message" /></td> </tr> </table> </form> and this is the php on the same application_form.php Code: [Select] <?php if (isset($_POST['submit'])) { // Collect variables $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; // Send email $body = "The following feedback has been submitted:\n\n"; $body .= "Name: $name\n"; $body .= "Email: $email\n"; $body .= "Message: $message"; mail ("cerberus478@gmail.com","Feedback Received",$body,"From: cerberus478@gmail.com"); // Output confirmation echo "<p>Your message has been received.</p>"; } ?> Hello, i have been looking for and answer on the internet but i couldn't find it! I'm new on PHP based on and example i wrote something like this for my website: //basic variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "example@mysite.org"; $Subject = "Registration u10"; $teamname = Trim(stripslashes($_POST['teamname'])); $affiliation = Trim(stripslashes($_POST['affiliation'])); $premier = Trim(stripslashes($_POST['premier'])); $challenge = Trim(stripslashes($_POST['challenge'])); $girls = Trim(stripslashes($_POST['girls'])); $boys = Trim(stripslashes($_POST['boys'])); //about 15 more variables go in here but i don't want to put them to save some space // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // email body text //this includes the info of all the variables at the top even the ones I didn't write in here (but you get the point ) $Body = ""; $Body .= "Team Name: "; $Body .= $teamname; $Body .= "\n"; $Body .= "\n"; $Body .= "AYSleague: "; $Body .= $aysleague; $Body .= "\n"; $Body .= "\n"; $Body .= "Flash Tournament: "; $Body .= $flashtournament; $Body .= "\n"; $Body .= "\n"; $Body .= "Spring 2011: "; $Body .= $spring2011; $Body .= "\n"; $Body .= "\n"; $Body .= "Summer 2011: "; $Body .= $summer2011; $Body .= "\n"; $Body .= "\n"; $Body .= "fall 2011: "; $Body .= $fall2011; $Body .= "\n"; $Body .= "\n"; // send email to my inbox with the information above $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // if everything goes OK it will redirect them to another page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thanksu12.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } ?> the problem that i have is: (i divided it in 2 sections) 1- i need to sent a second email to the coach 2- that email only needs to have the information of 6 variables not the whole thing I don't know how to do it, if someone knows how to do it, i will appreciate some help!! thanks! Hello, I have a registration page and when a user registers I want to send their email an activation code. To test I have the following code. <?php //Send activation Email $to = $Email_address; $subject = "www.WEBSITE.com/"; $message = "Welcome to my website!\r\rYou, or someone using your email address, has completed registration at WEBSITE. You can complete registration by clicking the following link:\rhttp://www.WEBSITE.com/register.php?action=verify&$activationKey\r\r If this is an error, ignore this email and you will be removed from our mailing list.\r\rRegards,\ "; $headers = 'From: noreply@abc.com' . "\r\n" . 'Reply-To: noreply@abc.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); if (mail($to, $subject, $message, $headers)) { echo 'Success'; } else { echo 'Error'; } ?> I have the last if else to see if it is sent to not. I do get a Success message, but I don't get an email at the address (I have checked the spam folder). I have checked the email address and it is correct. I have even waited a few hours and nothing. Why is the email not getting to my account? i wrote this code <?php $mail_to='XXX@gmail.com'; $subject_mail='UYYYY'; $message='XXXXX'; $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-type: text/html; charset=UTF-8 \r\n"; $headers .= "From: XXX@gmail.com \r\n"; mail($mail_to, $subject_mail, $message, $headers ); ?> but the email will not send why please? Hi guys, i have a custom made php that collect all the info in admin page (long story short), there's a button called "Approve" I would like to send back an email to user who applied with picture, once Approved button is pressed, so here's the script: <?php session_start(); $user = '123'; $pass = '123'; $to = $data['email']; $subject = 'blablabla'; $message = 'test123'; if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) { header('WWW-Authenticate: Basic realm="Enter password to access this page."'); header('HTTP/1.0 401 Unauthorized'); echo"You must be logged in to see this page."; exit; } ################## PROTECTED CONTENT ######################## require('./config.php'); ?> <!DOCTYPE HTML> <html> <head> <title>ADMIN PANEL</title> <style type="text/css"> body{width: 960px; margin: auto; margin-top: 20px; padding: 5px 20px; box-shadow: 0px 0px 2px #000000; border-radius: 5px;background:transparent url(images/bg_header.gif) top left repeat-x;} a:link,a:active,a:visited{color: inherit; text-decoration: none;} a:hover{text-decoration: underline;} .button{background:transparent url(images/grad.PNG) bottom left repeat-x; padding: 3px 5px; border-radius: 4px; border: 1px solid #cccccc;} .button:hover{border-color:orangered;text-decoration:none;} .approve .img{max-height: 200px; max-width: 200px; position: absolute; right: 5px; top: 5px;} .approve{display: block; height: 200px; overflow: hidden; box-shadow: 0px 0px 2px #000000; margin-top: 20px; padding: 20px; position: relative; font:13px verdana;} textarea,input{padding: 3px;font: 13px helvetica,verdana;border:1px solid rgb(51,151,251);border-radius: 4px;width: 300px; display: block; margin: 5px 0px;} input:hover,textarea:hover{border-color:orangered;cursor:pointer;} form{font:bold 13px verdana;} input[type='submit'],input[type='button']{width: auto;} </style> </head> <body> <?php echo" <div id='head'> <h1 align='center'>ADMIN PANEL</h1> <h4 align='center'><a href='index.php' class='button'>Homepage</a> <a class='button' href='admin.php'>Approval Queue</a> <a class='button' href='admin.php?edit'>Edit Image info.</a> <a class='button' href='?edit&view'>View Image Info.</a></h4> </div>"; if (isset($_GET['edit'])) { if (isset($_GET['pid'])) { $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); if (mysql_num_rows($pic) == 1) { if (isset($_POST['submit'])) { $approved = isset($_POST['approved']) && $_POST['approved'] == '1' ? 1 : 0; mysql_query('UPDATE `' . $table_name . '` SET ' . 'first_name = "' . $_POST['first'] . '",' . 'last_name="' . $_POST['last'] . '",' . 'phone="' . $_POST['phone'] . '",' . 'email="' . $_POST['email'] . '",' . 'first_name="' . $_POST['first'] . '",' . 'approved=' . $approved . ',' . 'address="' . $_POST['addr'] . '",' . 'admin_desc="' . $_POST['admin_desc'] . '"' . ' WHERE pid = ' . intval($_GET['pid'])) or exit("Unable to edit" . mysql_error()); echo'<h3>EDITED</h3>'; $pic = mysql_query('SELECT * from `' . $table_name . '` WHERE pid = ' . intval($_GET['pid'])); } $data = mysql_fetch_array($pic); if (isset($_GET['view'])) { echo' <strong>Uploaded by </strong>' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> <br /> <b>First_name :</b> ' . $data['first_name'] . ' <br /> <br /> <b>Last_name :</b> ' . $data['last_name'] . ' <br /> <br /> <b>Phone :</b> ' . $data['phone'] . ' <br /> <br /> <b>Email :</b> ' . $data['email'] . ' <br /> <br /> <b>Approved :</b> ' . ($data['approved'] == 1 ? 'Yes' : 'No') . ' <br /> <br /> <b>Address :</b> ' . $data['address'] . ' <br /> <br /> <b>Admin_description :</b> <br /> <br />' . $data['admin_desc'] . ' <br /> <br /> <a href="?edit&pid=' . $data['pid'] . '" class="button">Edit</a> <br /> <br /> '; } else { echo'<form method="POST" action="?edit&pid=' . intval($_GET['pid']) . '"> Editting photo: <a style="color:rgb(51,151,251);" href="' . $default_dir . $data['image_name'] . '">' . $data['image_name'] . '</a> uploaded by ' . $data['first_name'] . ' ' . $data['last_name'] . ' <br /> <img src="' . $default_dir . $data['image_name'] . '" style="max-width: 200px; max-height:200px; float: right;" /> <br /> First_name : <input type="text" name="first" value="' . $data['first_name'] . '" /> Last_name : <input type="text" name="last" value="' . $data['last_name'] . '" /> Phone : <input type="text" name="phone" value="' . $data['phone'] . '" /> Email : <input type="text" name="email" value="' . $data['email'] . '" /> Approved : <input type="text" name="approved" value="' . $data['approved'] . '" /> 0 or 1 Address : <textarea name="addr">' . $data['address'] . '</textarea> Admin_description : <textarea name="admin_desc">' . $data['admin_desc'] . '</textarea> <input type="submit" name="submit" value="Edit" /> </form>'; } } else { echo"NO SUCH PICTURE EXISTS"; } } else { echo" <h3>Search for image to " . (isset($_GET['view']) ? 'view' : 'edit') . " it: </h3> <form id='form' method='POST' action='admin.php?edit" . (isset($_GET['view']) ? '&view' : '') . "'> Uploader's first name: <input type='text' name='name' value='' /> OR Image name: <input type='text' name='img' value='' /> OR Email: <input type='text' name='email' value='' /> <input type='submit' name='submit' value='Search' /> </form>"; if (isset($_POST['submit'])) { $name = empty($_POST['name']) ? '%' : '%' . $_POST['name'] . '%'; $email = empty($_POST['email']) ? '%' : '%' . $_POST['email'] . '%'; $img = empty($_POST['img']) ? '%' : '%' . $_POST['img'] . '%'; $query = mysql_query( 'SELECT * from `' . $table_name . '` where ' . 'first_name like "' . $name . '" and ' . 'email like "' . $email . '" and ' . 'image_name like "' . $img . '"'); if (mysql_num_rows($query) > 0) { while ($pic = mysql_fetch_array($query)) { echo"<hr/><strong>Uploaded by $pic[first_name] $pic[last_name] " . date(' \a\t H:i \o\n d/m/Y', intval($pic['image_name'])) . "</strong> - <a href='$default_dir$pic[image_name]' target='_blank'>$pic[image_name]</a> <a href='?edit" . (isset($_GET['view']) ? '&view' : '') . "&pid=$pic[pid]' class='button'>" . (isset($_GET['view']) ? 'View' : 'Edit') . "</a>"; } } else { echo "NO IMAGE MATCHES THAT DESCRIPTION"; } } } exit; } if (isset($_GET['approve'])) { if (mysql_query('UPDATE `' . $table_name . '` SET approved = 1 WHERE pid = ' . intval($_GET['approve']))) { if (@mail($to, $subject, $message)) { echo('<p>Mail sent successfully.</p>'); } else { echo('<p>Mail could not be sent.</p>'); } echo"<h2>APPROVEDs</h2>"; } } It's not whole script though. Hi guys, I am writing the php script to send the email. I have noticed when I picked up on my email, I can see that it have been covered with mailed-by: myservername.com. I want to hide it, but I can't find a way to get it resolve. Here's the code: <?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 <$email>". "\r\n"; $to = "myname@myemail.com"; $subject = $type; $message = "$comments & $rate"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; mail($to, $subject, $message, $header, $add); echo "Thank you for sent us your email"; } } } ?> I guess that something got to do with this: if(isset($email)){ $header = "From: $name <$email>". "\r\n"; $header .= "MIME-Version: 1.0\l\n"; $add = "<$email>"; } I have disabled the safe-mode, so do you know how I can hide the mailed-by header using with the code on above?? Any advice would be much appreciate. Thanks in advance. |