Hey guys,

I'm using the PHP mail function on a contact form but some reason I can only seem to have the emails delivered to my gmail account. If I change the send to address to my work email - which is where I need the emails to be sent - they're never delivered.

I've checked my spam folder to see if they've been intercepted but there's just no sign of them. I've even tried a colleague's email address on a different domain and the end result is the same.

I just can't understand it. See my code below:

$submit=$_POST['submit'];

if (isset($submit))
{
$name=$_POST['frm_name'];
$telephone=$_POST['frm_telephone'];
$emailaddress=$_POST['frm_email'];

$message=$_POST['frm_message'];
$message=strip_tags($message);

$emailcontent = "Name = $name\n\nTelephone Number = $telephone\n\nEmail = $emailaddress\n\nMessage: $message";

$headers = 'From: ' . $name . "\r\nReply-To:" . $emailaddress;
mail("example@example.com", "Contact Form.", $emailcontent, $headers); 

}

    I think it's failing because your From variable is just a name ($name) and not an email address.

      Also note that the "From" email header should always be a valid e-mail address on your domain.

        Changing the from to a valid email address on the domain makes no difference whatsoever. It just makes no sense and I can't understand it.

        My initial concern was that maybe my host was somehow blocking emails sent through a form, marking them as SPAM. But then I wouldn't receive them to GMAIL.

        I've tried to use the PEAR Mail function but not yet had any joy and I'm not even sure it's installed by my host.

          Write a Reply...