简体   繁体   English

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

[英]sendmail sh: /usr/sbin/sendmail: Permission denied

I cannt send mail from php script although I can send it from command line with sendmail and我无法从 php 脚本发送邮件,尽管我可以从命令行使用 sendmail 和

php sendMyMail.php php sendMyMail.php

I have already tried these我已经尝试过这些

  1. httpd is running as apache user and I added apache user to smmsp group httpd 以 apache 用户身份运行,我将 apache 用户添加到 smmsp 组

  2. httpd_can_sendmail --> on 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

But in httpd error_log still showing this error但是在 httpd error_log 中仍然显示这个错误

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

Can anyone have any idea?任何人都可以有任何想法吗? I do really appreciate all your suggestions and really exhausted with this one.我真的很感激你的所有建议,对这个建议真的很累。

除了setsebool -P httpd_can_sendmail 1你还需要允许apache连接外: setsebool -P httpd_can_network_connect 1

That you can send emails from the command line does not mean that any user can (apache for instance).您可以从命令行发送电子邮件并不意味着任何用户都可以(例如 apache)。

Check that apache can actually send emails:检查 apache 是否真的可以发送电子邮件:

sudo -u apache sendmail root@localhost

Read the mail logfile (usually /var/log/mail.log) to see what happened.阅读邮件日志文件(通常是 /var/log/mail.log)以查看发生了什么。 Inbox of root is usually in /var/spool/mail/root ). root 的收件箱通常在 /var/spool/mail/root 中)。 Tipp: Use other user different from root if you don't want to use root as a guinea pig. Tipp:如果您不想将 root 用作豚鼠,请使用与 root 不同的其他用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM