Point Postfix to a Smart Host for a Specific Domain (Linux)

When sending mail to a specific domain, tell Postfix to send to a smart host (i.e. gateway or spam filter) rather than directly to the mail server.

Add a line to /etc/postfix/transport:

Create a postmap file:

Point Postfix to use the created postmap file by adding a line to /etc/postfix/main.cf:

Restart postfix:


Some large organizations often employ mail gateways, such as Proofpoint to filter incoming email for spam. If you are using a large web email provider, such as Hotmail, Yahoo, or Gmail, their mail servers will often be white-listed. But what if you are trying to send an email to a bank from your office’s tiny Postfix mail server? In this case, you will need to point your mail server to the bank’s mail gateway.

To do this, you need to create (or edit) your mail lookup table to include the bank’s domain, and point any email to their mail gateway, rather than directly to the mail server. This is accomplished via a postmap.

First, you need to create an entry in /etc/postfix/transport file. You can use any file of your choosing as long as you point to it, but by convention, the transport file is used. So, open it:

Add a line in the format domain.com smtp:smarthost.fqdn.com:port. Unless you are specifying a port (i.e. 587 for SSL connection), you can omit the :port section.

Save and exit the transport file (Ctrl-O then Ctrl-X if you are using nano). Then, generate a postmap file from your transport configuration:

And finally, point Postfix to use the previously generated map any time it restarts:

Save and exit the main configuration file, and finally, restart Postfix:


Vlad Dzhabarov.