yelzombob Posted March 5, 2013 Share Posted March 5, 2013 Hi I have a php/mysql application and I am trying to add a contact form from http://www.freecontactform.com/email_form.php I have uploaded the 2 files (as attached). Whereas all the validation stuff works fine as does the 'success' message, the email is not being received. Is there something simple that I'm missing? All help gratefully appreciated. Bobcontactform.phpsend_form_email.php Quote Link to comment https://forums.phpfreaks.com/topic/275273-contact-from-working-but-email-not-being-received/ Share on other sites More sharing options...
davidannis Posted March 5, 2013 Share Posted March 5, 2013 Did you edit lines 5 and 6 in send_form_email.php? Quote Link to comment https://forums.phpfreaks.com/topic/275273-contact-from-working-but-email-not-being-received/#findComment-1416763 Share on other sites More sharing options...
yelzombob Posted March 5, 2013 Author Share Posted March 5, 2013 Yes - line 5 was changed to my email address (double-checked to make sure its right) and line 6 was edited so that I'd know where the email came from Quote Link to comment https://forums.phpfreaks.com/topic/275273-contact-from-working-but-email-not-being-received/#findComment-1416767 Share on other sites More sharing options...
DavidAM Posted March 5, 2013 Share Posted March 5, 2013 // 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); 1) Turn on error reporting: error_reporting(-1); ini_set('display_errors', 1);at the beginning of your scripts (at least in development). 2) Remove the "@"-sign on the call to mail(). In fact, forget that you ever saw or heard of that operator. It simply hides errors (warnings, notices, whatever) it does NOT "fix" them. 3) Use an IF statement to see if the call to mail() worked: if (! mail(...)) { echo 'Failed to send the mail'; }without #2 and #3, you really do NOT know if the mail is being sent or not 4) The From: ... header MUST specify an email address that has the authority to send email from the email server you are using. If you try to send mail from gmail.com with an address of @yahoo.com, the server may refuse to send it or the receiving server may refuse to accept or deliver it or may put it in the SPAM folder. It may be considered as a forged message. Use the Reply-To: ... (as you have) to include the form's user in the email headers, but the "From:" header needs to be your website's email address. If you get any errors after implementing #1 and #2, post them here so we can help more. If you are running on a Windoze machine, you may need to check your mail settings in the PHP.ini file. Quote Link to comment https://forums.phpfreaks.com/topic/275273-contact-from-working-but-email-not-being-received/#findComment-1416809 Share on other sites More sharing options...
yelzombob Posted March 6, 2013 Author Share Posted March 6, 2013 Hi Thanks for the help 1. I included the error reporting code at the beginning of the scripts and removed the "@" sign from the beginning of the call to mail(). Tested it and it ran through the process - validation worked ok and when submitted I got the success message, but no email. 2. I then added the 'if' statement after the call to mail and got the success message again, but no email delivered 3. Following your comments in 4) I then changed the 'email to:' address to a hotmail address and the email was delivered and received ok. The message format is fine. The original email address (the one that didn't work) was to an address on the same domain as the website that is sending the email. It's on a linux VPS with 1&1 and is currently the only domain that is on there. The mail account is not managed through the VPS Plesk Panel, but via the 1&1 hosting panel I have another, simpler, windows hosting service with 1&1 so I changed the 'email to:' address to an address on one of the domains on there and that was delivered & received ok - albeit into Junk (the hotmail one was received into the main inbox). If it's relevant, the email was delivered twice in each case. Is there any way that I can get it delivered to the original email address? As all my emails come into the same outlook I know that I can set up a rule to 'move' the email into the correct folder, but would like to be able to have it delivered directly if possible. Again, thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/275273-contact-from-working-but-email-not-being-received/#findComment-1416894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.