Alex Rivera | Logout

mail() fails, but returns true

Asked 2011-05-27T19:35:30.063
14

I am trying to use the php mail() function on my server. Weirdly, it returns true but I do not receive anything in my email inbox.

Yet the cpanel email forwarder is working fine.

So prolly it's not a configuration thing since the forwarder sends me emails?

I tried adding in:

ini_set("sendmail_from", "do-not-reply@gmail.com");

But that didn't work.

Here's my code:

$subject = "My Subject";
$body = "Email Body ";
$headers = 'From: do-not-reply@domain.com' . "\r\n" . 
    'Reply-To: do-not-reply@domain.com' . "\r\n" . 
    'X-Mailer: PHP/' . phpversion(); 

if (mail($email,$subject,$body,$headers))
    echo "Sent!";
else
    echo "Fail!";
Edit
Report

1 Answer

1

I had this problem with a script that I was using that was sending from and receiving at the same domain. Have you tried sending the email to an email address the resides on a different domain? This might help narrow down the possible issues.

answered 2011-05-27T19:43:39.733

Your Answer