3

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?

R.75
  • 59
  • 9

1 Answers1

1

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.

Kondybas
  • 686
  • 6
  • 15
  • Thanks for the response, but this results in: Expected response code 220 but got code "", with message "" – R.75 May 30 '16 at 14:27
  • How do you get that response? And where? – Kondybas May 30 '16 at 16:57
  • It is the response I get from swiftmailer after I try to send an email. – R.75 May 31 '16 at 07:08
  • I fixed the error by adding : at "bounce_processor" but it doesnt run the script – R.75 May 31 '16 at 12:54
  • 1
    Ooops! Sorry for typo! Script should be executable by effective `exim` user - usually `mailnull`. Look at exim logs for details. – Kondybas May 31 '16 at 20:58
  • This doesn't work at all! Tried every which way. Either I'm missing something or this answer needs way more clarification on what exactly needs to be done. – shrimpwagon Oct 30 '19 at 14:32