使用Postfix使用PHP Mail时权限被拒绝

时间:2016-02-02 17:17:19

标签: php email ubuntu postfix-mta

我已正确安装了postfix和dovecot,并根据本指南进行了所有配置:http://www.krizna.com/ubuntu/setup-mail-server-ubuntu-14-04/

但是当我尝试通过终端发送邮件时:

sudo php -r "mail('xyz@xyz.com', 'test', 'test');"

它给了我错误

sh: 1: /etc/postfix: Permission denied

我尝试chmod -R 777/etc/postfix目录,我仍然遇到同样的错误。

我该怎么做才能让这个工作?我只想将邮件从我的服务器发送到其他邮件,如Gmail(即xyz@xyz.com到abc@gmail.com)

我甚至在我的dns管理器中配置了mx记录和记录。

如果我看到Postfix日志,我就有了这个:

Feb 2 12:30:33 myhost postfix/pickup[16695]: ED7A120FD3: uid=33 from=<www-data> Feb 2 12:30:33 myhost postfix/cleanup[4891]: ED7A120FD3: message-id=<20160202173033.ED7A120FD3@xyz.com> Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: hash:/etc/postfix/virtual lookup error for "xyz@xyz.com" Feb 2 12:30:33 myhost postfix/cleanup[4891]: warning: ED7A120FD3: virtual_alias_maps map lookup problem for xyz@xyz.com -- message not accepted, try again later 我在Ubuntu 14.04上使用运行Apache 2的PHP 7

(注意:Postfix和dovecot似乎正在工作,因为我按照教程中的说明进行了telnet并获得了正确的响应。)

2 个答案:

答案 0 :(得分:0)

您忘记了sudo postmap /etc/postfix/virtual

答案 1 :(得分:0)

解决了我的问题。仅在从终端访问Postfix时发生权限错误。从PHP脚本访问时它可以工作。

此外,我必须修改我之前设置为/ etc / postfix的PHP.ini sendmail路径。

相关问题