Sendmail Error
There're errors NOQUEUE: SYSERR(apache) in maillog while sending mails by PHP.
[root@web ~]# tail -f /var/log/maillog
...
Jan 6 20:38:11 web sendmail[2703]: NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied
It seems a permission issue. It could be blocked by SELinux, so let's check SELinux boolean value of sendmail.
[root@web ~]# getsebool -a | grep sendmail
httpd_can_sendmail --> off
logging_syslogd_can_sendmail --> off
Solution
You can see httpd_can_sendmail is turned off. Let's turn it on by setsebool. It may take a while.
[root@web ~]# setsebool -P httpd_can_sendmail on
[root@web ~]# getsebool -a | grep mail
httpd_can_sendmail --> on
logging_syslogd_can_sendmail --> off
Don't forget to restart httpd after enabling it.
[root@web ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Now, let's try to send a mail by PHP again. This time, it succeeded. I received the new mail in mailbox. Let's see the maillog again.
[root@web ~]# tail -f /var/log/maillog
...
Jan 6 21:06:46 web sendmail[2752]: s06D6kSB002752: from=apache, size=812, class=0, nrcpts=1, msgid=<[email protected]>, relay=apache@localhost
Jan 6 21:06:47 web sendmail[2753]: s06D6kF9002753: from=<[email protected]>, size=1035, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=example [127.0.0.1]
Jan 6 21:06:47 web sendmail[2752]: s06D6kSB002752: to=<[email protected]>, ctladdr=apache (48/48), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30812, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s06D6kF9002753 Message accepted for delivery)
Jan 6 21:06:51 web sendmail[2755]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
Jan 6 21:07:06 web sendmail[2755]: s06D6kF9002753: to=<[email protected]>, ctladdr=<[email protected]> (48/48), delay=00:00:19, xdelay=00:00:19, mailer=esmtp, pri=121035, relay=gmail-smtp-in.l.google.com. [173.194.79.27], dsn=2.0.0, stat=Sent (OK 1389013626 r7si54762570pbk.207 - gsmtp)
Now, the problem is resolved.