- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools






Mail Server#MTA (mail transfer agent)

Postfix Relay Configurations

General relay

From Trusted network, Any Destination

mynetworks =,

From UnTrusted network, Relay Permit Destination

myhostname =
mydomain =
mydestination = $myhostname, localhost.$mydomain, localhost
relay_domains = $mydestination,,

Relay a specific email address to another server

Method1. Create mail aliases in /etc/aliases

  • No need to create users
  • do not leave the original email

reflect /etc/aliases

# newaliases

Method2. .forward setting of mail forwarding

~/.forward (/home/user1/.forward)

Forward all emails and do not leave the original email

Forward all emails and leave the original email


Relay email addresses for a particular domain to another server

relay_domains =,
transport_maps = hash:/etc/postfix/transport
/etc/postfix/transport     smtp:[x.x.x.x]      smtp:[x.x.x.x]
Reflect settings
postmap  hash:/etc/postfix/transport
systemctl reload postfix

Change delivery destination by sender(From:)

You can use sender_dependent_default_transport_maps or sender_dependent_relayhost_maps.

Method1. sender_dependent_default_transport_maps

sender_dependent_default_transport_maps = hash:/etc/postfix/sender_dependent_transport
/etc/postfix/sender_dependent_transport        stmp:[x.x.x.x]:25    stmp:[x.x.x.x]:25

Method2. sender_dependent_relayhost_maps

Overridden in transport table

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhost
/etc/postfix/sender_dependent_relayhost        [x.x.x.x]:25    [x.x.x.x]:25

middleware/mail/postfix/relay.txt ยท Last modified: 2020/07/01 by admin

Page Tools