Wordpress SMTP Plugin Will Not Send E-Mails
Writing this article, because I have run into the issue multiple times and always seem to forget the fix.
Quick Overview: I use DigitalOcean as a host. I build my own servers using CentOS7, the most current WP version and the Contact Form 7 plugin, which uses postfix to send SMTP mail (no one-click apps). These fixes are applicable to any LAMP/LEMP stack using postfix.
I have experienced one of two scenarios. The first entails losing SELinux contexts when the /etc/postfix/main.cf is copied into the directory. To fix this, perform the following:
Open a terminal and type the following to restore the original security context:
restorecon -v /etc/postfix/main.cf
If your context for those files is set correctly, you'll also need to be sure the Apache (httpd) user has SELinux permission to send mail via SMTP.
The following is a SELinux configuration that will need to be turned on for SMTP send to work properly.
Verify if the setting is on or off by opening a terminal and typing the following:
getsebool httpd_can_sendmail
If your output reads httpd_can_sendmail --> off you will need to enable this setting using the following command:
sudo setsebool -P httpd_can_sendmail 1
-P in the above command means Persistent (across reboots).
After reload your postfix and apache/httpd services
service httpd reload && service postfix restart
Now you should be able to use an SMTP Wordpress Plugin with your self-built server.