首页 > 解决方案 > 如何使用 postfix 和 php 处理退回邮件?

问题描述

使用 Postfix 和 PHP 我想处理退回邮件。

我首先像这样构建一个后缀服务器:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-postfix-e-mail-server-with-dovecot

然后从 master.cf 配置

https://thecodingmachine.io/triggering-a-php-script-when-your-postfix-server-receives-a-mail

我能够将所有传出的电子邮件内容发送到我的 php 脚本,但我怎样才能只将退回电子邮件发送到这个脚本?

邮件发件人:

$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'Reply-To: bounce@example.com';
$headers[] = 'Return-Path: bounce@example.com';
$headers[] = 'From: Example <postmaster@example.com>'


mail('Example <example@example.com>', "subject", "msg", implode("\r\n", $headers), "-f bounce@example.com");

master.cf 拾取将所有外发电子邮件发送到 example.php。我尝试使用反弹而不是拾取但没有成功。

pickup    fifo  n       -       -       60      1       pickup
       -o content_filter=myhook:dummy

myhook unix - n n - - pipe
  flags=F user=www-data argv=/var/www/example.php ${sender} ${size} ${recipient}

我做错了什么?

谢谢

标签: phpdebianpostfix-mtaemail-bounces

解决方案


我终于在https://serverfault.com/questions/322657/how-can-i-route-some-emails-to-a-script-in-postfix找到了解决方案。

答案以:“好的。现在采用不同的方法。”


推荐阅读