Jump to content

Contact from working but email not being received


yelzombob

Recommended Posts

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

Link to comment
Share on other sites

 

// 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.

Link to comment
Share on other sites

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. 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.