PHP mail returns TRUE, but e-mail is not sent

匿名 (未验证) 提交于 2019-12-03 03:04:01

问题:

Simple code:

mail("my_email@gmail.com", $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!

回答1:

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)



回答2:

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.



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!