postfix manually bounce messages

Solution 1:

However, what you probably mean is to force-bounce a recipient, which is the real issue, not the message.

Asked before elsewhere in 2011. After setting up Wietse's configuration below, you could postmap, postfix reload, and flush the queue, forcing that recipient/message pairing to slam into the new transport rule.

Bob Proulx: I have been trying to deduce if it is possible to force a message waiting in the mail queue with temporary errors (domain name resolution failures) to bounce right now instead of waiting for the timeout.

Wietse says:

It would be incorrect to force a message to bounce. Messages can have multiple recipients. It would be more correct to force-bounce a recipient.

To flag a destination or recipient as undeliverable:

/etc/postfix/main.cf: transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport: typodomain.example error:5.1.2 Bad destination system address

Flagging one recipient in a queue file as undeliverable requires a lot of code that currently does not exist: 1) a way for postsuper to mark as "expired" one recipient in the middle of a list of recipients, 2) a way to extract from the defer logfile the record that says why that recipient was not yet delivered for use in the non-delivery notification, and 3) a way to mark that defer logfile record as "deleted" so that the problem won't be reported again.

Wietse

Solution 2:

No. It is not possible, as there is only minimal need of doing manual queue management. There are configuration parameters for doing it automatically: http://www.postfix.org/QSHAPE_README.html#deferred_queue and http://www.postfix.org/postconf.5.html#bounce_queue_lifetime (but remember the fatal downside of reducing bounce_queue_lifetime)

The best way would be to notify the sender about the delay and just wait until it bounces on its own: http://www.postfix.org/postconf.5.html#delay_warning_time

Tags:

Postfix