Friday, 4 March 2016

Sendmail issue on CentOS 7 (Log permission denied in /var/log/maillog)



Apache/PHP on CentOS 7 unable to send emails using sendmail

See log in /var/log/maillog file should shows following error:


[root@linuxcnf ~]# grep Permission denied /var/log/maillog
“sendmail [4884]: NOQUEUE: SYSERR(apache): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied”
……….

Quick Solution

Option -1: Disable Selinux and restart the server:

[root@linuxcnf ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
:wq
[root@linuxcnf ~]# service httpd restart

Change from enforcing to permissive or disabled and reboot the server.

Option -2: Or use the below command to enable selinux security for apache to send mail:

[root@linuxcnf ~]# setsebool –P httpd_can_sendmail on
[root@linuxcnf ~]# service httpd restart

Now apache/php should able to send mail using sendmail service.

No comments:

Post a comment