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", "[email protected]");
But that didn't work.
Here's my code:
$subject = "My Subject";
$body = "Email Body ";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email,$subject,$body,$headers))
echo "Sent!";
else
echo "Fail!";
Return Value: Returns the hash value of the address parameter, or FALSE on failure. Note: Keep in mind that even if the email was accepted for delivery, it does NOT mean the email is actually sent and received!
There are a myriad of reasons that could cause this problem. Here are a few:
mail()
returns true when the outgoing mail server accepts the message for delivery. You will need to troubleshoot the other possibilities to find the point of failure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With