Linux – dynamically forward bounce_notice_recipient to external address using postfix

emaillinuxpostfix

Ok I've been banging my head over this for hours. I'm trying to forward all bounced messages to an external bounce processor regardless of domain. There are dozens of domains in use at any given time and occasionally there are domains being added and removed. In an attempt to try and keep it dynamic, I've added the following lines in postfix main.cf:

notify_classes=bounce
bounce_notice_recipient=postmaster

From what I understand, this will forward a copy of all bounces to postmaster. I'm aware that bounced mail is returned to the sender, however the goal is to forward a copy of all bounces from all domains as long as they were sent from the local smtp. When I tried this, I received the following error:

undeliverable postmaster notification discarded

So my question is what is going on here? Is this a problem with local delivery? And how would I forward mail coming into postmaster to an external address?

And the bigger question is: Is this the best strategy to deliver all bounced mail from a server, regardless of domain (without managing a list of domains), to an external address?

I'll appreciate any input.

Best Answer

From what I understand, this will forward a copy of all bounces to postmaster.

This is incorrect; the documentation for bounce(8) clearly states that bounce notification recipients will receive notifications of bounced messages, including a configurable portion of the original message.

Bounces themselves are not configurable, and are addressed to the message's Return-Path: as mandated by the RFC.

If your desire is to have bounces delivered to a specific mail server, investigate the mailing list management features postfix offers, and set the correct Return-Path: on outgoing messages.