sendmail sh: /usr/sbin/sendmail: 权限被拒绝


sendmail sh: /usr/sbin/sendmail: Permission denied

我不能从 php 脚本发送邮件,尽管我可以使用 sendmail 从命令行发送邮件,并且

php sendMyMail.php

我已经尝试过这些

  1. httpd 以 apache 用户身份运行,我将 apache 用户添加到 smmsp 组

  2. httpd_can_sendmail --> 上

  3. SELinux status:                 enabled
    SELinuxfs mount:                /selinux
    Current mode:                   permissive
    Mode from config file:          enforcing
    Policy version:                 24
    Policy from config file:        targeted
    

但是在httpd error_log中仍然显示此错误

sh:/

usr/sbin/sendmail: 权限被拒绝

谁能知道? 我非常感谢您的所有建议,并且对此感到筋疲力尽。

您可以从命令行发送电子邮件并不意味着任何用户都可以(例如 apache(。

检查 apache 是否真的可以发送电子邮件:

sudo -u apache sendmail root@localhost

阅读邮件日志文件(通常是/var/log/mail.log(以查看发生了什么。根目录的收件箱通常位于/var/spool/mail/root 中。Tipp:如果您不想将root用作豚鼠,请使用与root不同的其他用户。

除了setsebool -P httpd_can_sendmail 1之外,您还需要允许 apache 在外部连接:setsebool -P httpd_can_network_connect 1