Postfix“邮件到脚本”管道仅传递空消息

Postfix“邮件到脚本”管道仅传递空消息

我这里有一个问题。

我希望将收到的电子邮件通过 postfix 传送到系统中的 php 脚本。

我的系统正在运行 ispconfig 3、postfix 和 dovecot(<虚拟邮箱用户保存在 mysql 中)。

我已经研究过这个了:如何配置 postfix 以将所有传入的电子邮件传送到脚本?

...脚本已执行,但没有向脚本传递任何“消息”。到目前为止我的设置:

在 ISPConfig 3 中我设置了以下电子邮件路线:

Active      Server          Domain              Transport   Sort by
Yes         example.com     pipe.example.com    piper:      5

摘自我的 postfix master.cf:

piper   unix  -       n       n       -       -       pipe
    user=piper:piper directory=/home/piper argv=php -q /home/piper/mail.php

到目前为止它运行良好(邮件已发送至[电子邮件保护])(邮件日志):

Jun 21 16:07:11 example postfix/pipe[10948]: 235CF7613E2: to=<[email protected]>, relay=piper, delay=0.04, delays=0.01/0.01/0/0.02, dsn=2.0.0, status=sent (delivered via piper service)

...并且 mail.err 中没有错误

mail.php 成功执行(其 chmod 为 777 并且 chown 为 piper),但创建了一个空的 .txt 文件(通常它应该包含电子邮件消息):

-rw------- 1 piper piper    0 Jun 21 16:07 mailtext_1340287631.txt

我使用的 mail.php 脚本来自http://www.email2php.com/HowItWorks

如果我使用他们的(商业)服务通过提供的“pipe-email”将电子邮件传送到 mail.php(在 apache2 环境中),则消息将成功完整地保存。但正如您所见,我不想使用外部服务。

-rw-r--r--  1 web2 client0  1959 Jun 21 16:19 mailtext_1340288377.txt

那么,这里出了什么问题?我认为这与我系统中的“交付配置”有关...

答案1

这是因为你的 PHP 脚本是废话。它不会将 STDIN 保存到文件中。而是将未初始化(空)变量保存到文件中。这就是它为空的原因。

您应该学习 PHP 来解决这个问题。

相关内容