我目前正在运行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脚本没有被正确调用,但我在任何日志中都没有“错误”。
以前有没有人经历或修复过这个问题?
答案 0 :(得分:1)
来自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.
所以我希望这就是这个意思:
test: |"php -q /var/blahblahblah/php/test.php"