-   Linux - Server (
-   -   Disable NDR on Postfix Revisited (

isomtech 11-24-2009 09:26 AM

[SOLVED] Disable NDR on Postfix Revisited
Greetings all!
I have a conundrum that I'm hoping someone can help me with.
As you can tell by the subject, I'm looking to disable NDR messages from being sent on my Postfix server. I've read dozens of posts of other people trying to ask the same question, and there's a pattern I've noticed: Every post is answered with a lecture on why you shouldn't do that, but none have said "no, that can't be done". I don't want a lesson on how mail servers are supposed to work. I fully understand the ramifications of what I wish to accomplish. I just want to know if it is possible to disable this behavior, and if so, a hint or two on how I might accomplish this. I did find one post making reference to notify_classes, but after reading the documentation I don't think this is what I am looking for.

In case you're wondering if disabling NDR on this server will destroy the world as we know it, know this: This server does not serve as a destination for anyone's mail. This server is a MX backup for a primary system that goes down very infrequently. The primary has a rather nice spam filter that rejects mail it knows to be spam during the SMTP session. Putting the same spam filter on the backup MX is not an option I have available to me. I have added several sender restrictions to Postfix to reduce the number of illegitimate messages that it stores and forwards.

I want to further reduce the unnecessary SMTP traffic by eliminating the NDR messages for the messages that my backup does accept, and the primary does not.

I hope this doesn't come off too crass, but I have spent much of my time lately reading through post after post on dozens of forums and mail lists. They all lecture on why you shouldn't do this, with no lecture making a good case for my particular situation. I just hope to get a simple answer - can it be done and how might one suggest I do it?

Thank you!

roybal 11-25-2009 11:29 AM

Since nobody has responded....
I don't know how to do it either, but I have a few ideas. The qmgr actually tracks undeliverable mail and sends the NDR. The first time a message is tried and fails, it goes to the deferred queue. When it reaches max_tries, it goes to the bounce queue. By default these are:
/var/spool/postfix/bounce/* non-delivery records
/var/spool/postfix/defer/* non-delivery records
I would (attempt to) remove the bounce inode and replace it with a symlink to /dev/nul
Mail going to the bounce queue would then silently pass out of existence.

Disclaimer: I have never actually done this...

isomtech 11-25-2009 11:48 AM

A very interesting idea, for sure. The only problem I foresee with that is, Postfix will try to create a file in that directory rather than send something to that file. I don't know what will happen in that instance. I would think that I would get an error stating that is a file and not a directory during the file creation attempt. I may have to do some tests to see how that would behave.

isomtech 11-25-2009 11:56 AM

Yeah, it has issues. I did a quick and dirty test so see if it would throw errors.

$ ln -s /dev/null my
$ touch my/nostril
touch: cannot touch `my/nostril': Not a directory

Now that doesn't mean that it won't prevent the bounce messages from being sent. I'll have to play with that concept a bit. Thanks for the idea!
I still have a hard time accepting that there is no configuration directive to accomplish this. With as granular as the configuration options are, there has to be something to just switch that off. I've read through the postconf man page and I can't find anything though...

isomtech 11-30-2009 12:30 PM

Anyone else have a definitive answer on this? My concern is simply this:

84 messages sent
2 messages expired and returned to sender
17 messages removed from queue

I'm sending out an awful lot of NDRs. I don't want to contribute to the worthless bandwidth hog that is spam. In one day, I've sent out 84 NDR messages that probably bounced and just wasted CPU cycles and bandwidth. This is down considerably since I added RBL and other sender restrictions to the Postfix config. I would like to reduce this further by not sending NDRs, since the only time this would actually have a negative impact is when my primary is down, and only if my primary were down for longer than the queue lifetime.

isomtech 12-17-2009 09:15 AM

I finally did it!
There may be a more refined way to accomplish this, but this was the best solution I could come up with. I modified the file and changed one line.

bounce    unix  -      -      n      -      0      bounce
should be changed to:

bounce    unix  -      -      n      -      0      discard
Now it's not without it's drawbacks. In the logs I have identified an error that get's thrown whenever this runs the discard handler instead of the bounce handler. The errors I get look like this:

Dec 15 16:07:40 websrv1 postfix/discard[15220]: warning: unexpected attribute nrequest from bounce socket (expecting: flags)
Dec 15 16:07:40 websrv1 postfix/discard[15220]: warning: deliver_request_get: error receiving common attributes

however, the behavior is what I have been looking for. Messages get queued and stored and deferred as they should, but bounced messages just disappear.

I'll report back if I discover some other ramifications, but so far it appears to be solid. This morning was the 1st time I've seen the logwatch report show the same number of messages delivered and removed from queue. (usually the delivered messages were on the order of 20x larger than the removed from queue figure)

All times are GMT -5. The time now is 08:25 PM.