Postfix: Resend ‘hard’ bounces

blacklistemailemail-bouncespostfix

I had a number of messages get rejected by the recipient's mail server with a status 550 code due to an IP address blacklist. I've sorted the problem that caused the host to become blacklisted, and removed the entry from the blacklist.

I'd like to have Postfix resend the messages that failed (they're automated code-review e-mails for the development team, so somewhat important). Is this possible, and if so, what's the best approach? If Postfix can't be made to automatically resend these messages, is there at least a way to recover them so that they can be manually resent?

Best Answer

You can use smtp_reply_filter feature to transform hard reject to soft reject when sending email. The idea was given by this thread.

In main.cf, add this line

smtp_reply_maps = pcre:/etc/postfix/smtp_5xx_to_4xx

and in /etc/postfix/smtp_5xx_to_4xx, add the line

if !/^5[0-9][0-9][ -]5\.1\.[0-9] /
    /^5(.*)$/ 4$1
endif