Php
php mail() 權限被拒絕 /var/spool/exim 和 /var/log/exim
全新安裝 CentOS 7、Exim 4.84、Httpd 2.4.6、php 5.4.16
通過 exim 發送郵件。使用 sendmail-command 在控制台中發送郵件有效。在 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
這通常是SELinux 問題,您需要設置正確的布爾值:
setsebool -P httpd_can_sendmail on