Wednesday, January 10, 2018

Apache not sending emails on Centos 7

Applications on Apache webserver that are working fine but can't send out emails is a real headache. Especially if everything was working on the development server. Example of error encountered;

Could not execute: /usr/sbin/sendmail

In Wordpress, it refuses to send email. Once such instance is the Forget password window and you see the message
The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.

This is ONE possibly most common situation. 

On most Development servers, the SELinux is probable turned OFF or in permissive mode. However on the Production servers, they are almost always set to ON. In the web server document directory, check if the following SELinux status;

$ getsebool httpd_can_sendmail

It should be in status OFF. Change the status to ON and restart Apache with the command

$ setsebool -P httpd_can_sendmail on
$ systemctl restart  httpd.service

Second common situation

Still not receiving emails from apache or Wordpress? It is possible Postfix SMTP server is using values that the email relay SMTP is not accepting. Check the maillog for any errors such as this;

said: 450 4.1.8 <apache@production.localdomain>: Sender address rejected: Domain not found (in reply to RCPT TO command))  

Or

sendmail[2450]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied

This is a story for another time.

No comments:

Blog Archive