简体   繁体   中英

How to send an (exim) email bounce to a php file

I am currently working on a Centos 7 server which uses exim to handle emails in combination with swiftmailer. When an email bounces the "error" will be send to my email address. Instead of receiving the bounce as an email, I would like to be able to send the "error" to a script. If been looking for a way to do this, but I am unable too find the answer online.

Is there a way to accomplish this at all? If so how can it be done?

You have to write one router and one transport.

Router should detect the bounce message by sender that is <> . So you have to place the next config at the beginning of routers section:

begin routers:
bounce_processor:
  driver    = accept
  condition = ${if eq{$sender_address}{"<>"}}
  transport = bounce_script
  unseen
. . . . . 

Verb unseen means that message processing shouldn't stop after matched router but rather message is processed in two different ways simultaneously. One way leads to the inbox while other - to the script.

Next you have to create the transport. Order of transports doesn't matter:

bounce_script:
  driver  = pipe
  command = /path/script -arg1 -arg2

Here message is passed via pipe to the stdin of the executable launched with some args. That's all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM