How to handle bounce email with postfix and php?

最后都变了- 提交于 2020-01-06 05:43:11

问题


Using Postfix and PHP i would like to handle bounce email.

I first build a postfix server like this :

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

then master.cf configuration from

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

I'm able to send all outgoing email content to my php script, but how can i only send bounce email to this script ?

Mail sender:

$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 pickup send all outgoing email to example.php. I tried to use bounce instead of pickup but without success.

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}

What i am doing wrong ?

Thanks


回答1:


I finally found the solution on https://serverfault.com/questions/322657/how-can-i-route-some-emails-to-a-script-in-postfix.

The answer starting with : "Okay. And now a different approach."



来源:https://stackoverflow.com/questions/55619256/how-to-handle-bounce-email-with-postfix-and-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!