1

我目前正在运行 Postfix 服务,可以正常发送和接收电子邮件。我正在尝试使用别名“测试”地址来运行 PHP 脚本。请参阅下面的别名文件摘录。

test: "| php -q /var/blahblahblah/php/test.php"

这是test.php的内容。这似乎在命令行中正确运行。

#!/usr/bin/php
<?php
$file = fopen("/tmp/postfixtest", "a");
fwrite($file, "Script successfully ran at ".date("Y-m-d H:i:s")."\n");
fclose($file);
?>

下面是 mail.log 的摘录,显示了感兴趣的主要行。

postfix/qmgr[3427]: 02BE9472A: from=<sender@email.com>, size=1681, nrcpt=1 (queue active)
postfix/virtual[3435]: 02BE9472A: to=<test@domain.com>, relay=virtual, delay=0.45, delays=0.42/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
postfix/qmgr[3427]: 02BE9472A: removed

请注意括号中的传递到 maildir 位。这应该说“交付给脚本”之类的东西吗?

现在所有文件都设置为 777 权限,别名文件通过使用保持更新sudo newaliases

似乎 PHP 脚本没有被正确调用,但我在任何日志中都没有收到“错误”。

有没有人经历过或解决过这个问题?

4

1 回答 1

1

from man aliases

|command
       Mail  is piped into command. Commands that contain special char-
       acters, such as whitespace, should be  enclosed  between  double
       quotes. See local(8) for details of delivery to command.

       When  the  command  fails, a limited amount of command output is
       mailed back to the  sender.   The  file  /usr/include/sysexits.h
       defines  the expected exit status codes. For example, use "|exit
       67" to simulate a "user unknown" error, and "|exit 0" to  imple-
       ment an expensive black hole.

so I would expect this is what is meant:

test: |"php -q /var/blahblahblah/php/test.php"
于 2012-04-04T03:15:03.973 回答