Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Amazon EC2 instance running with RedHat/Linux. My problem is with the PHP mail() function which is not working although I can send mail with sendmail from command line.

I run this command.

$ telnet localhost 25
Connected to localhost.
Escape character is '^]'.

My php.ini setting is

[mail function]
SMTP = localhost
smtp_port = 25
sendmail_path = /usr/sbin/sendmail -t -i
mail.add_x_header = On

I can't figure out whats wrong. I am not getting any PHP mail error. I don't get any email as well. What could the problem be?

/var/log/maillog is

Jan 15 04:00:33 ip-xx-xx-xxx-xx sendmail[16041]: q0F90XIe016041: from=root, size=2486, class=0, nrcpts=1, msgid=<201201150900.q0F90XIe016041@ip-xx-xx-xxx-xx.eu-west-1.compute.internal>, relay=root@localhost
Jan 15 04:00:33 ip-xx-xx-xxx-xx sendmail[16042]: q0F90XvT016042: from=<root@ip-xx-xx-xxx-xx.eu-west-1.compute.internal>, size=2849, class=0, nrcpts=1, msgid=<201201150900.q0F90XIe016041@ip-xx-xx-xxx-xx.eu-west-1.compute.internal>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain []
Jan 15 04:00:33 xx-xx-xxx-xx sendmail[16041]: q0F90XIe016041: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32486, relay=[] [], dsn=2.0.0, stat=Sent (q0F90XvT016042 Message accepted for delivery)
share|improve this question
So what do you see in /var/log/{maillog,messages}, /var/log/httpd/{access,error}_log? What's the output from mailq? Is root getting any mail about boubced messages, etc? –  Alien Life Form Jan 17 '12 at 11:09
I added the var/log/maillog and there is nothing about mail error in httpd/access,error_log. Thanks –  kingzuphur Jan 17 '12 at 11:35
Is PHP logging anything at all ? Make sure the php error log goes somewhere. –  adaptr Jan 17 '12 at 12:00
maillog shows messages sent from root to root. Since their date is 4:00 AM, I suspect they may be from the nightly cron run (but check their content anyway, just in case). So if sendmail logs nothing, it means it is never contacted. You'll have to start checking your code to find out why... –  Alien Life Form Jan 17 '12 at 14:27
Can you post a code sample that shows how you are calling mail()? –  adamo Jan 17 '12 at 21:10
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.