Relay Postfix email through another server for bounces
I would like Postfix to try to deliver an email itself initially and, only if there is a bounce, then try to send through a relay.
The scenario is that we moved an existing website, with users we need to email, to a new server with a new IP that major email providers are bouncing out of hand. I know I need to warm up the IP but the problem is how to ensure delivery while we warm up the IP? Seems like a Catch-22.
My idea is to try through our new IP address and, only on bounce, try again through a warmed up IP that we already mail from.
I know how to relay all Postfix email to another Postfix server but I hope I can do a conditional relay only on receiving a bounce so that we can eventually warm up this new IP.
Solution 1:
postconf -e soft_bounce=yes
postconf -e smtp_fallback_relay=otherhost:port
postconf -e bounce_queue_lifetime=0
soft_bounce (default: no)
Safety net to keep mail queued that would otherwise be returned to the sender. This parameter disables locally-generated bounces, changes the handling of negative responses from remote servers, content filters or plugins, and prevents the Postfix SMTP server from rejecting mail permanently by changing 5xx reply codes into 4xx. However, soft_bounce is no cure for address rewriting mistakes or mail routing mistakes.
Note: "soft_bounce = yes" is in some cases implemented by modifying server responses. Therefore, the response that Postfix logs may differ from the response that Postfix actually sends or receives.
Example:
soft_bounce = yes
bounce_queue_lifetime (default: 5d)
Consider a bounce message as undeliverable, when delivery fails with a temporary error, and the time in the queue has reached the bounce_queue_lifetime limit. By default, this limit is the same as for regular mail.
Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks). The default time unit is d (days).
Specify 0 when mail delivery should be tried only once.
This feature is available in Postfix 2.1 and later.
smtp_fallback_relay
smtp_fallback_relay (default: $fallback_relay) Optional list of relay hosts for SMTP destinations that can't be found or that are unreachable. With Postfix 2.2 and earlier this parameter is called fallback_relay. By default, mail is returned to the sender when a destination is not found, and delivery is deferred when a destination is unreachable. With bulk email deliveries, it can be beneficial to run the fallback relay MTA on the same host, so that it can reuse the sender IP address. This speeds up deliveries that are delayed by IP-based reputation systems (greylist, etc.). The fallback relays must be SMTP destinations. Specify a domain, host, host:port, [host]:port, [address] or [address]:port; the form [host] turns off MX lookups. If you specify multiple SMTP destinations, Postfix will try them in the specified order. To prevent mailer loops between MX hosts and fall-back hosts, Postfix version 2.2 and later will not use the fallback relays for destinations that it is MX host for (assuming DNS lookup is turned on).