Reputation: 21739
Simple code:
mail("[email protected]", $subject, $text);
It doesn't send email, but it still, returns TRUE. What is hapenning?
P.S. Even if I add headers, the result is the same!
Upvotes: 13
Views: 9613
Reputation: 146302
from the man page for mail():
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
Basically there is nothing you really can do in plain ol' PHP unless you actually check the wire to see what is going on. I would suggest using some mail library that has some indication of whether the mail sent or not (if it exists)
Upvotes: 12
Reputation: 163272
See @Neal's comment. Simply returning true
means very little.
You should check your PHP.ini and make sure your SMTP servers are set correctly (if on Windows) or that your sendmail path (Linux) is correct. From there, check your sendmail configuration.
Upvotes: 2
Reputation: 4208
Do you know for a fact the email is not sending? The email could go from your php script to your SMTP server, but get dropped somewhere between the first SMTP server and gmail.
Try looking at network traffic to verify that the email is being sent using something similar to wireshark.
Upvotes: 3