php mail() 权限被拒绝 /var/spool/exim 和 /var/log/exim

php mail() 权限被拒绝 /var/spool/exim 和 /var/log/exim

全新安装 CentOS 7、Exim 4.84、Httpd 2.4.6、php 5.4.16

通过 exim 发送邮件有效。使用 sendmail 命令在控制台中发送邮件有效。使用 php 中的 mail() 发送邮件会出现以下错误消息(在 /var/log/maillog 中):

Aug  2 15:03:04 v024 exim[1311]: 2016-08-02 15:03:04 1bUZLc-0000L9-D3 Failed to create spool file /var/spool/exim/input//1bUZLc-0000L9-D3-D: Permission denied
Aug  2 15:03:04 v024 exim[1311]: 2016-08-02 15:03:04 1bUZLc-0000L9-D3 Cannot open main log file "/var/log/exim/main.log": Permission denied: euid=93 egid=93
Aug  2 15:03:04 v024 exim[1311]: exim: could not open panic log - aborting: see message(s) above

检查文件权限,一切正常:

drwxr-x---. 2 exim exim     4096 Aug  2 14:32 /var/log/exim
-rw-r-----. 1 exim exim 19351762 Aug  2 15:11 /var/log/exim/main.log
-rw-r-----. 1 exim exim     1010 Aug  2 08:46 /var/log/exim/reject.log

drwxr-x---. 6 exim exim       75 Jul 19 13:25 /var/spool/exim
drwxr-x---. 2 exim exim       94 Jul 13 21:01 /var/spool/exim/db
-rw-r-----. 1 exim exim      382 Jul 19 13:25 /var/spool/exim/exim-process.info
drwxr-x---. 2 exim exim    36864 Aug  2 15:11 /var/spool/exim/input
drwxr-x---. 2 exim exim    20480 Aug  2 15:11 /var/spool/exim/msglog
drwxr-x---. 2 exim exim        6 Aug  2 13:01 /var/spool/exim/scan

答案1

这往往是一个SELinux 问题, 你需要设置正确的布尔值

 setsebool -P httpd_can_sendmail on

相关内容