我有一个运行 Apache 2.2 和 PHP 5.3 的 CentOS 6.2 虚拟机,我试图通过 PHP 的 mail() 函数发送电子邮件.我可以毫无问题地从 CLI 发送电子邮件,但是当 PHP 尝试时它会失败.在 sendmail 日志中如下:
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
似乎 Apache 没有执行此操作的权限,但我不确定如何修复它.我发现了很多关于此的讨论,但没有足够具体到我可以使用的我正在做的事情.任何帮助,将不胜感激.谢谢!
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!
首先要检查权限是否正确.这是我系统中的以下权限
First you have to check if permission are correct. Here is the permission below in my system
# ls -l/usr/sbin/sendmail.sendmail
-r-xr-sr-x root smmsp/usr/sbin/sendmail.sendmail
# ls -l/var/spool/clientmqueue
drwxrwx--- smmsp smmsp/var/spool/clientmqueue
如果您的权限或所有权错误,请使用 chown 和 chmod 进行更改.
If your permissions or ownership is wrong then change it using chown and chmod.
如果上述情况正确,则禁用 selinux,或者如果您希望启用 selinux,请使用 chcon 设置正确的 selinux 上下文.
If the above is right then disable selinux or if you want selinux enabled use chcon to set the correct selinux context.
http://docs.fedoraproject.org/en-US/Fedora/13/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-SELinux_Contexts_Labeling_Files.html
要暂时禁用 selinux,请使用 #setenforce 0
For disabling selinux temporarily use #setenforce 0
这篇关于如何允许apache发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!