Page 1 of 1

PHP mail function reporting mail sent but mail never receive

Posted: Thu Nov 13, 2008 2:01 pm
by clem_c_rock
Hello,
I have a script that suddenly stopped working and nothing's been changed. I am using the php mail() function to send a simple email form and the mail() function report true when it is fired off but I can never receive the emails.

I suspect something's changed in our hosting but wanted to rule everything out before I started investigating there.

Here's the simple code I am using:

Code: Select all

 
      $send_tenant_mail = mail( $tenant_email, $subject, $body_header, "From: $from\nReply-To: $from\n" );
          if($send_tenant_mail == 1)
      { 
          $confirm = "A Confirmation Email has been sent to: $tenant_email";
      }
 

Thanks,
Clem C

Re: PHP mail function reporting mail sent but mail never receive

Posted: Thu Nov 13, 2008 2:59 pm
by infolock
Try this instead:

Code: Select all

 
if(false == mail( $tenant_email, $subject, $body_header, "From: $from\r\nReply-To: $from\r\n" )) {
  echo "FAILED TO SEND!";
  exit;
}
 

Notice \r\n is used...


If no "FAILED TO SEND" is seen, then this can be 1 of a few issues, none are a result of PHP failure though...

1) Mail server could have a huge que and your message you are trying to send out hasn't been gotten to.

2) An email in the server has hung and the server is trying to infinately send it back out (iow, no one set a max retry)

3) the server connection has failed.

4) there is other issues with the mail server

5) check your spam box, might have ended up there.


I am making a huge assumption here and assuming you have access to the server's terminal and it's running linux with mail installed. try sending an email from command prompt. otherwise, the server may not be accepting emails from the account you are trying to send from (ie www) or another configuration is needed.


short answer: check mail server or spam box


hope this helps.