1

I read up on using relayhost with Postfix 2.6.6. It's possible to use different relay hosts, with different credentials, for different senders. But how do I use direct delivery with specific senders (in this case, only one sender), while all other mail gets sent via a single relay host/credential (in this case, Sendgrid).

Background: all mail is transactional and generated by web applications on different domains on the LAMP server where Postfix runs. No MX records for any of these domains points to this server (they are mostly google apps). All domains, except one, sucessfully use the sendmail>postfix>sendgrid>remote SMTP route. This one domain/application needs to send directly (sendmail>postfix>remote SMTP) in order to implement better delivery tracking. I don't want to use direct delivery via SwiftMailer itself, because it introduces latency in the application's mail processing. I want SwiftMailer to use the Swift_SendmailTransport and deliver via Postfix, and then we will comb the Postfix logs for delivery failures.

Gaia
  • 1,855
  • 5
  • 34
  • 60

1 Answers1

2

You can set your default relayhost using the relayhost configuration parameter, and then override this per sender using sender_dependent_relayhost_maps configuration parameter. Notice that the last one is a lookup table.

Finally, you will need to set smtp_sasl_password_maps to configure per relayhost smtp credentials. Remember you probably need to enable smtp sasl authentication: smtp_sasl_auth_enable=yes. You may need to configure other smtp parameters (maybe stmp_tls_*, etc).

Migtor
  • 369
  • 1
  • 7
  • Relayhost is already working fine via sendgrid. Your first paragraph seems very useful. Let me check on that and get back to you. Thanks – Gaia Sep 18 '14 at 13:04
  • Can sender_dependent_relayhost_maps specify that an user should not use a relay? – Gaia Oct 03 '14 at 19:51
  • 1
    What do you want to achieve? – Migtor Oct 06 '14 at 15:55
  • have some senders go thru a relay, others not. – Gaia Oct 06 '14 at 19:23
  • 1
    Just not listing the senders in the file should be enough, their mails would be routed through the default relayhost. If what you want is to make some users avoid any relayhost, even the default one, then you should not use relayhost parameter, and put the default relayhost in a default "catch all" entry in the table: `* smtp:default_relayhost`. Then, you would list the senders you want to avoid any relayhost with null parameters: `sender@domain.com :`. – Migtor Oct 07 '14 at 16:10