【问题标题】:Error with permissions sending mail with Apache + PHP without changing permission to 777在未将权限更改为 777 的情况下使用 Apache + PHP 发送邮件的权限出错
【发布时间】:2012-03-14 23:56:04
【问题描述】:

除非我将 /var/spool/clientmqueue 的权限更改为 777,否则我无法让 sendmail 从 apache+php 工作。

/var/spool/clientmqueue 的所有权

drwxrwxrwx 2 smmsp mail 4096 Jul 19 11:50 clientmqueue

我弄乱了 smmsp 和 apache 的用户组。

id apache
uid=48(apache) gid=48(apache) groups=48(apache),12(mail)

id mail
uid=12(mail) gid=12(mail) groups=12(mail),48(apache)

SELinux 被禁用

getsebool httpd_can_sendmail
getsebool: SELinux is disabled

如果我将文件夹权限设置为 770,则在邮件日志中

NOQUEUE: SYSERR(apache): can not write to queue directory
/var/spool/clientmqueue/ (RunAsGid=48, required=12): Permission denied

不会发送任何邮件,我会从 php 收到错误消息。

如果我将文件夹设置为 0777,那么我会在邮件日志中得到它

dangerous permissions=40776 on queue directory /var/spool/clientmqueue/

但是 php 可以正常发送邮件。

是否有可能让它与 0770 和 apache 一起工作,并在组中读取邮件。我知道错误是获取 apache 的主 GID 48,但它也共享组 12。

任何帮助都会很棒。

【问题讨论】:

    标签: php apache sendmail


    【解决方案1】:

    这个对我有用。在 Ubuntu 机器上遇到此错误之前,我遇到了其他错误。让我分享一下,以防其他人遇到他们。我得到 NOQUEUE: SYSERR(www-data): can not chdir(/var/spool/mqueue-client/): Permission denied。

    usermod -a -G smmsp www-data
    chmod 770 /var/spool/mqueue-client     (don't use 775, it gives dangerous permission error in the log)
    service apache2 restart (this is required for the above to take effect)
    Now sending email gives a different error.
    - NOQUEUE: SYSERR(www-data): can not write to queue directory /var/spool/mqueue-client/
    - chmod 4555 /usr/sbin/sendmail
    - Above command fixed the email issue. => didn't see any error in the mail.log this time.
    

    【讨论】:

    • 您,先生,拯救了我的一天!谢谢!
    【解决方案2】:

    我今天也遇到了同样的问题(来这里寻找答案)。

    我最终找到了this overview;从该列表运行以下命令为我解决了这个问题:

    chmod 4555 /usr/sbin/sendmail
    

    这会在 sendmail 二进制文件上设置setuid special mode,大概允许 Apache 以邮件用户的身份发送邮件。

    (我在运行之后重新启动了 apache 和 sendmail 守护程序,但我不确定哪些实际上需要重新启动)

    我仍然非常好奇是什么导致这个问题摆在首位......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 2016-12-28
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      相关资源
      最近更新 更多