I have a CentOS 6.2 virtual machine running Apache 2.2 and PHP 5.3 that I'm trying to send email from via PHP's mail() function. I can send email from the CLI without problems but when PHP tries it fails. In the sendmail log is the following:
Oct 9 11:42:03 localhost sendmail[3080]: NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied
It seems like Apache doesn't have permission to do this but I'm not sure how to fix it. I've found a lot discussion about this but nothing specific enough to what I'm doing that I could use. Any help would be appreciated. Thanks!
Selinux may cause the issue, to verify run:
getsebool -a | grep mail
If it displays as bellow it is selinux:
allow_postfix_local_write_mail_spool --> off
You may disabled it, but if you want to keep it (and you should as it provides an extra layer of security) you should do something else:
setsebool -P httpd_can_sendmail on
This will allow the httpd to send emails, as when you use php mail().
Hate to necro this, but none of the solutions here worked for me. I know very little about SELinux, but I ended up discovering the problem with this (on CentOS 6):
getsebool httpd_can_sendmail
Which told me it's disabled. Fixed with
setsebool httpd_can_sendmail 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With