cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:mail:postfix:relay



Mail Server#MTA (mail transfer agent)

Postfix Relay Configurations

General relay

From Trusted network, Any Destination

mynetworks = 192.168.0.0/16, 127.0.0.0/8


From UnTrusted network, Relay Permit Destination

myhostname = smtp.example.com
mydomain = example.com
mydestination = $myhostname, localhost.$mydomain, localhost
relay_domains = $mydestination, test1.com, test2.com


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
/etc/aliases
user1: user1@example.com



reflect /etc/aliases

# newaliases


Method2. .forward setting of mail forwarding

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

Forward all emails and do not leave the original email

test@example.com



Forward all emails and leave the original email

\user1
test@example.com




Relay email addresses for a particular domain to another server

/etc/postfix/main.cf
relay_domains = example.com, example.jp
transport_maps = hash:/etc/postfix/transport
/etc/postfix/transport
example.com     smtp:[x.x.x.x]
example.jp      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

/etc/postfix/main.cf
sender_dependent_default_transport_maps = hash:/etc/postfix/sender_dependent_transport
/etc/postfix/sender_dependent_transport
@example.com        stmp:[x.x.x.x]:25
@sub.example.com    stmp:[x.x.x.x]:25


Method2. sender_dependent_relayhost_maps

Overridden in transport table

/etc/postfix/main.cf
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_dependent_relayhost
/etc/postfix/sender_dependent_relayhost
@example.com        [x.x.x.x]:25
@sub.example.com    [x.x.x.x]:25



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

Page Tools