SELinux allow webserver to send email

Apache_selinux_php_emailYou might have came across the problem that your website or wordpress installation cannot send any emails. Even after configuring PHP and your webserver correctly, the email is still not sent.

When you try, for example, to request a forgotten password, WordPress will try to send an email to you. Instead of the email you will see WordPress reporting the following error:

Advertisements
your host may have disabled the mail() function

Your first instinct might be to check php.ini, but you will probably not find the reason for this error message there. More likely you will find a corresponding message in the apache logfile:

sendmail: fatal: chdir /var/spool/postfix: Permission denied

This error indicates that SELinux is blocking apache from sending mail. As already shown in my Migrate WordPress site with minimal downtime article, SELinux provides predefined rulesets for some functionality. These can be enabled with boolean switches. The boolean switch to allow apache to send emails is called “httpd_can_sendmail”:

$ setsebool -P httpd_can_sendmail=on

This command will enable the rules to allow apache to send emails.


Read more of my posts on my blog at http://blog.tinned-software.net/.

This entry was posted in Linux Administration, Security and tagged , , . Bookmark the permalink.