2011/09/30

PHP mail does not work

The OS is linux, and the webserver is apache, and in php.ini file the mail is set as 'sendmail_path = /usr/sbin/sendmail -t -i'. The problem is that php mail() function does not work, although it returns 1 like it's successful. In this case you will not find any help by looking into apache error log. The debugging should start from maillog, which is located at /var/log/ if you are not specify the different loction in the php.ini. I saw the errors like,
delay=00:00:06, xdelay=00:00:02, mailer=relay, pri=120481, relay=*****, dsn=4.5.0, stat=Operating system error
sendmail[24572]: ruleset=try_tls, arg1=mail.***.com, relay=mail.***.com, reject=451 4.3.0 Temporary system failure. Please try again later.
which is actually hard to tell what's going on. I actually tested it mail function thru command line. Accidentally I found if I am root, I was able to send the mail. And I dig more into mail log, I found some useful error logs (note that those logs were generated by the test through url, not command line), like
sendmail[24572]: p8S0pDSY024569: SYSERR(apache): db_map_open: cannot pre-open database /etc/mail/access.db: Permission denied
So then the issue is clear. I checked the /etc/mail/access.db, the mod was 640, so changed to 644, and it sloved the problem.

No comments:

Post a Comment