How to setup a email relay with the Postfix SMTP server ?

Email relay is an email server which forwards incoming SMTP emails to an another SMTP server. Postfix can be setuped as an email relay.

First, you should ensure which domaisn are being forwarded (eg. domain-A-to-be-relayed.com and domain-B-to-be-relayed.net), and hostname of destination SMTP server which you expects emails for these domains forwarding to. (eg. destination_host of these domains).

Edit /etc/postfix/main.cf:

transport_maps = hash:/etc/postfix/transport
relay_domains = domain-A-to-be-relayed.com, domain-B-to-be-relayed.net

Edit /etc/postfix/transport:

domain-A-to-be-relayed.com   smtp:destination_host.domain-A-to-be-relayed.com
domain-B-to-be-relayed.net smtp:destination_host.domain-B-to-be-relayed.net

Regenerate the hash table and reload the Postfix daemon.

$ postmap /etc/postfix/transport 
$ /etc/init.d/postfix reload

Related posts

Sammy Fung

Sammy is the manager of Linux Harbour with 20+ year experience in Linux and open source technology.