maps - transport maps

最後更新: 2019-10-21

 

介紹

在 postfix 上, 它一共有幾個不同的 map 去控制 transport

 - default_transport (default: smtp:)
 - local_transport (default: local:$myhostname)
 - relay_transport (default: relay:)
 - virtual_transport (default: virtual:)
 - transport_maps (default: empty)

transport_maps

    Optional lookup tables with mappings from recipient address to
    (message delivery transport, next-hop destination)

目錄

  • Transport Agents
  •  

Transport Agents

 

  • discard
  • static
  • smtp
  • relay

 


Agent: discard, static

 

main.cf

transport_maps = hash:/etc/postfix/transport_maps static:virtual

transport_maps

postmaster@Domain        smtp:Another.MailServer
Domain                   discard:No other remote mailbox

 * 在此設定, "Domain" 係唔 work 的. 原因係 lookup "U@D" 後就會到 "static:",

    所以不會 lookup "D"

修改

main.cf

transport_maps = hash:/etc/postfix/transport_maps

transport_maps

postmaster@Domain        smtp:Another.MailServer
Domain                   discard:No other remote mailbox
*                        virtual

 


virtual_transport (default: $virtual_transport)

 

在 main.cf 內有設定 transport_maps, 它是用 recipient address 來決定 E-Mail 的去向的

如果想做到 per domain, per user 的設置時, 我們可以用兩個 maps 去實現

transport_maps = proxy:mysql:/etc/postfix/mysql/transport_maps_user.cf,
                 proxy:mysql:/etc/postfix/mysql/transport_maps_domain.cf

表的格式(sql 的 return value):

transport:nexthop           # 常見有 smtp:[your_clients_server]:25

transport: Refers to an entry from master.cf (smtp)

nexthop:

  • 1. MX lookup,
  • 2. A record,
  • 3. [..] | IP

P.S.

transport: 在 master.cf 上的 "service type"

不用 mysql 的版本:

#1 查看原本的 map 先

postconf transport_maps

transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf

#2 修改 /etc/postfix/main.cf

# 設定本地有什麼 Domain
virtual_mailbox_domains = /etc/postfix/virtual_mailbox_domains

# 每個 "virtual_mailbox_domains" 用什麼轉發
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf,
 regexp:/etc/postfix/transport_maps

P.S.

virtual_mailbox_domains 不用 tables !!

transport_maps 不可以用 hash type!!

/etc/postfix/transport_maps

# for bounce mail
/.*@bounce.xxx.com$/               email_script

# 去 go.to 的信經 via.gateway 出
/.*@go.to/            smtp:[via.gateway]:25

Remark: 修改完後要 postfix reload

/etc/postfix/virtual_mailbox_domains

bounce.xxx.com

 


個別 Mailbox 在不在本機(在 remote)

 

假設有以下情況:

Local:

test@???

Remote:

sales@???
contact@???

設定:

works while sending out email:

smtpd_reject_unlisted_recipient = no    <-- 因為那 User 不在 local, 他們是 unlisted_recipient

在 smtpd_recipient_restrictions = ....... 上要刪除 reject_unlisted_recipents

transport:(per-user transport)

Add

sales@???, contact@???           smtp:[your_clients_server]:25

 


sender_dependent_default_transport_maps (default: empty)

 

A sender-dependent override for the global default_transport parameter setting.
The tables are searched by the envelope sender address and @domain.
A lookup result of DUNNO terminates the search without overriding the global default_transport parameter setting.

Note: this overrides default_transport, not transport_maps, and therefore the expected syntax is that of default_transport

default_transport (default: smtp)

The default mail delivery transport and next-hop destination for destinations that do not match $mydestination,
$inet_interfaces, $proxy_interfaces, $virtual_alias_domains, $virtual_mailbox_domains, or $relay_domains.

Specify a string of the form transport:nexthop, where transport is the name of a mail delivery transport defined in master.cf.

 


virtual_alias_domains (Default: $virtual_alias_maps)

 

 


default_transport

 

Default: smtp

transport and next-hop destination for destinations that do not match

  1. $mydestination,
  2. $inet_interfaces,
  3. $proxy_interfaces,
  4. $virtual_alias_domains,
  5. $virtual_mailbox_domains,
  6. $relay_domains

nexthop destination is taken from:

  1. $sender_dependent_default_transport_maps,
  2. $default_transport,
  3. $sender_dependent_relayhost_maps,
  4. $relayhost

設定:

default_transport = uucp:relayhostname

 


 

Creative Commons license icon Creative Commons license icon