If you see an error like
SMTP -> ERROR: Failed to connect to server: Permission denied (13)
, you may be running into SELinux preventing PHP or the web server from sending email. This is particularly likely on RedHat / Fedora / Centos.
Using the getsebool
command we can check if the httpd daemon is allowed to make a connection over the network and send an email:getsebool httpd_can_sendmail
getsebool httpd_can_network_connect
This command will return a boolean on or off. If it's off, we can turn it on:
sudo setsebool -P httpd_can_sendmail 1
sudo setsebool -P httpd_can_network_connect 1