I am trying to set up postfix to send bounced messages to an external script
to log the bounce to an external logging service so that we can monitor
bounce rates to different recipient domains. I want to keep the default
bounce behavior intact, so bounce notices are still send to the original
sender.

I have been hunting and testing different configurations for 2 days and
haven't had success, yet, in figuring it out.

First I tried changing the bounce service to use a pipe command:
in master.cfg I changed to bounce service to this "bounce unix - n n - -
pipe flags=Fhq user=bouncelog argv=/usr/local/bin/bounches.sh ${sender}
${recipient}"

I found somewhere people recommending not to do this because it is a system
critical service. This also destroys the default bounce behavior, which I'm
trying to keep intact. It generated the following errors, but it is probably
not the right approach anyway:
smtp postfix/pipe[13243]: warning: unexpected attribute nrequest from bounce
socket (expecting: flags)
smtp postfix/pipe[13243]: warning: deliver_request_get: error receiving
common attributes


Next I tried a custom transport for bounce notification emails
in main.cfg
notify_classes = bounce
bounce_notice_recipient = boun...@domain.com

at the top of my transport map:
boun...@domain.com    bounces:

in master.cfg:
bounces   unix  -       n       n       -       -       pipe
   flags=FXhq user=bouncelog argv=/usr/local/bin/bounces.sh ${sender}
${recipient}

I was sure to run `postmap /etc/postfix/transport` after making changes to
the transport and `postfix reload` after modifying config files.

This one appeared to be working, but it doesn't quite. It has a few issues.
${sender} ends up being "double-bou...@smtp.domain.com" and ${recipient} is
"boun...@domain.com". I believe, however, by looking at the logs that this
issue is caused because the bounce_notify email is actually sent, then
bounces, and that bounce notification is the one that gets logged instead of
the original bounce. I haven't found what I'm doing wrong, but it seems to
not be the correct approach since I want to log the bounce not parse an
email about the bounce.


We have an ebook copy of "Postfix - The Definitive Guide". I've read
everything in it regarding bounces and pipes. I haven't found anything that
points me in the right direction or answers my questions.


I'm wondering if anyone on the list can point me to the right documentation
and give me some pointers as to what I'm missing and what I need to
correct/fix to get this working.  I'm almost to the point just writing a
script that tails the maillog and parses any line with "status=bounced" or
"status=deferred" in it.  I would like something a little more real-time and
fault tolerant, though, and I'd like to do it correctly.

Thanks in advance for your help!




--
View this message in context: 
http://postfix.1071664.n5.nabble.com/piping-bounce-service-to-external-program-tp60729.html
Sent from the Postfix Users mailing list archive at Nabble.com.

Reply via email to