views:

143

answers:

1

Is there a way to configure postfix to use a relay only if direct delivery is rejected? The case being a web application that has to send notification to subscribers, but some servers reject the connection. I want those cases to be retried using a paid SMTP relay like authsmtp.com. However I don't want to use the relay for everything since it costs per mail.

A: 

This is definitely a serverfault.com question. Also, the answer is a somewhat ugly hack and not recommended under normal situations.

You will need to ignore the permanent response error codes. For this, in main.cf: soft_bounce = yes

This converts all 5xx errors to 4xx errors (including nosuchuser responses and all that).

Set authsmtp.com as your relayhost in main.cf: relayhost = [whatever.authsmtp.com]:port

Setup your Postfix to authenticate for relaying via authsmtp.com (via IP if they allow it, or see http://www.postfix.org/SASL_README.html#client_sasl for how to enable SMTP AUTH in the Postfix smtp client).

Devdas