Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get postfix to run a script on soft (4xx) and hard (5xx) delivery errors, but I'm not sure where to start.

If I understand things correctly, I could insert (pipe-based) filters in the file, there's a whole 'milter' infrastructure available, an finally I suppose I could simply grep through the logs.

So - any advice? Should I go the 'handle it via' route, and if so, what daemon should I intercept? 'bounce'? The grep-the-logs route is probably simplest, but I can't help but feel that there is a better way.

Any advice appreciated!

share|improve this question
up vote 1 down vote accepted

Postfix is an MTA - a mail transfer agent. Delivery is done by either one of the built-in MDA's (mail delivery agents) - local(8) or virtual(8) - or any external MDA configured by you.

If delivery fails for any reason, this fact is logged and the message is either deferred for later retry (on 4xx statuses), or rejected and a bounce message sent back to the sender (on 5xx statuses.)

There is no point in the above path where you can arbitrarily inject alternative code; these actions are mandated by the SMTP protocol (RFC5321).

You can fully determine what happens upon message delivery to an MDA; you would have to program that to handle error statuses in whatever way suits your scenario.

EDIT: that said, you could write a pipe(8)-based wrapper around your chosen delivery agent that handles these delivery results.

share|improve this answer
Ok - so a pipe-wrapper around the local(8) delivery agent may allow me to do what I want? Note - I don't want to change anything of the default behaviour, but just inform an external process of what's going on. (basically: stop the external process from generating mail for adresses that are bouncing) – edovino Mar 28 '12 at 12:46
No, pipe(8) is the delivery process; you'd need to employ an external MDA to take care of the actual delivery (such as maildrop or deliver.) – adaptr Mar 28 '12 at 13:09
right! got it - thx! – edovino Mar 28 '12 at 15:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.