PHP mail() function not delivering mail

♀尐吖头ヾ 提交于 2019-12-13 17:03:54

问题


I have a slight problem. I am using a working script (works on my testing account - shared server) to send a mail through PHP using the mail() function.

I just got a dedicated server, and I haven't been able to get the function to work. I've spent the last 10 or so hours reading various documentations on BIND (for the SPF record), dovecot, sendmail and postfix trying various things to get this to work.

There is clearly something that I am missing.

So we know the PHP code works fine. All the headers are fine everything. We know this as it's a direct copy from my testing account. So the problem must arise somewhere in the server config. The path to sendmail is correct, and sendmail is (apparently) working fine. I've set up the script to now deliver "Sent" or "Error" based on the boolean result from the PHP mail() function. That is:

if(mail($blah,$blah,$blah,$blah,$blah)) { echo "Sent"; } else { echo "Error";}

And the result ALWAYS comes up as "Sent" - however, the email never arrives. Can someone suggest things to check, as I'm completely new to this (24 hours or so!).

Thanks in advance.

Ryan


回答1:


Have you tried the mailq command to see if there are errors? Here's an answer to a similar question on ServerFault with more detail.




回答2:


Did you install a SMTP server. The php mail function will not work unless you install one. For example, under linux, you can install postfix. Under windows, MS exchange is an example.



来源:https://stackoverflow.com/questions/4632173/php-mail-function-not-delivering-mail

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