Sending email from server using SMTP (SMTP Error, Permission denied)

I face below error for quite sometimes.

1
SMTP -> ERROR: Failed to connect to server: Permission denied (13)
After going through a lot of configuration and research, the problem occurred by SELinux is blocking the communication.
SELinux does not allow Apache (httpd,phpmailer) to use the sendmail function and make any sort of network connection.

However, the solution was found that we need to enable the sendmail protocol manually on Centos due to SELinux.
We can check the protocol setting by following below command
1
getsebool httpd_can_sendmail
And the solution is
1
2
3
4
5
setsebool -P httpd_can_sendmail 1
OR
/usr/sbin/setsebool -P httpd_can_sendmail on

No comments: