[Apache/WordPress/Sendmail/Selinux] WordPress won’t send email

If WordPress won’t send emails and you’re running selinux you likely need to enable Apache’s ability to use sendmail.  If this is the case you’ll see something in /var/log/audit/audit.log:

type=SYSCALL msg=audit(1455126829.120:44783832): arch=c000003e syscall=82 success=no exit=-13 a0=7fff665d7c20 a1=7fff665d8c20 a2=fff a3=7fff665d5ed0 items=0 ppid=18828 pid=13442 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=51 sgid=51 fsgid=51 tty=(none) ses=6664 comm=”sendmail” exe=”/usr/sbin/sendmail.sendmail” subj=unconfined_u:system_r:httpd_t:s0 key=(null)

It’s a very simple fix to allow Apache to use sendmail:

setsebool -P httpd_can_sendmail 1

There are a lot of other reasons sending mail may fail from WordPress but this one is likely to pop up in selinux environments.  Another common fix is ensuring that localhost traffic isn’t blocked via iptables.