Postfix管道电子邮件到PHP,权限错误

时间:2012-03-16 22:57:23

标签: permissions ssh pipe postfix-mta permission-denied

我正在尝试使用technique mentioned here使用我的Postfix邮件服务器将电子邮件发送到PHP并遇到以下错误...

Mar 16 22:52:52 s15438530 postfix/pipe[9259]: AD1632E84C63: to=<php@[myserver].com>, relay=plesk_virtual, delay=0.61, delays=0.59/0/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command output: /bin/sh: /var/www/vhosts/[myserver].com/httpdocs/clients/emailpipe/email2php.php: Permission denied 4.2.1 Message can not be delivered at this time )

如果有人能为我解释这个问题,我真的很感激。我试过777'的电子邮件目录,但无济于事。我哪里错了?

非常感谢。

4 个答案:

答案 0 :(得分:9)

来自后缀文档...

  

出于安全原因,使用别名数据库所有者的权限执行到命令和文件目标的传递。默认用户标识default_privs用于向root拥有的别名中的命令/文件传递。

所以你有两个选择,在main.cf中设置 default_privs 以匹配email2php文件的所有权。

或者,应该有一种方法来创建由用户拥有的别名数据库而不是postfix / nobody。我以前没试过这个,但是不能这么说。

答案 1 :(得分:3)

我已通过禁用SELINUX 解决了此问题。

答案 2 :(得分:2)

确保你有

#!/usr/bin/php
<?php

(或者你的PHP路径是什么 - 在服务器上做“哪个php”) 在每个php脚本的顶部,每个php脚本文件都是可执行的

chmod +x /var/.../email2php.php

另外,请确保您可以从命令行测试脚本:

cat some_rfc822_email.txt | /var/.../email2php.php

并获得您想要的结果

答案 3 :(得分:0)

要解决此问题,您需要chown或chmod /var/www/vhosts/[myserver].com/httpdocs/clients/emailpipe/email2php.php由postfix用户执行。或者,您需要重新定义此用户以成功执行该文件。

仅仅更改目录的权限(除非您使用-R)是不够的。

为了说明其工作原理,请考虑以下玩具示例:

<me>@harley:~$ touch test
<me>@harley:~$ ls -al test
-rw-r--r-- 1 <me> <me> 0 2012-03-26 23:44 test
<me>@harley:~$ sh test
<me>@harley:~$
<me>@harley:~$ ./test
bash: ./test: Permission denied
<me>@harley:~$ chmod 755 test
<me>@harley:~$ ./test
<me>@harley:~$ 

为了通过正在运行的shell直接执行文件,需要将其设置为可执行文件。其他调用(例如,sh email2php.phpphp email2php.php)仅需要读访问权限,因为它们完全将执行链接到不同的文件。

首先可能导致问题的原因,请参阅here