简体   繁体   中英

PHP mail() function not delivering mail

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM