在 Postfix 上完全更改收件人

在 Postfix 上完全更改收件人

我想要實現的是,任何發送的電子郵件[email protected]都會被重寫[email protected]並發送到[email protected].

canonical_maps和都virtual_alias_maps致力於交付給備用收件人。當我讀到文件它告訴我,使用canonical_maps,cleanup進行完全重寫。

然而,實際上,電子郵件仍然具有to原始收件人的信息。因此,當查看 bob 郵箱中的電子郵件時,它會顯示一封給 joe 的電子郵件。

不知怎的,我覺得我在這裡錯過了一些東西。

配置:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 2d
canonical_maps = hash:/etc/postfix/canonical
config_directory = /etc/postfix
header_checks = pcre:/etc/postfix/header_checks
home_mailbox = Maildir/
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
mailbox_size_limit = 0
maximal_queue_lifetime = 4d
milter_default_action = accept
milter_protocol = 2
mydestination = ...
myhostname = ...
mynetworks = ...
myorigin = /etc/mailname
non_smtpd_milters = inet:localhost:8891
readme_directory = /usr/share/doc/postfix
recipient_delimiter = +
relayhost =
smtp_fallback_relay = ...
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name
smtpd_milters = inet:localhost:8891
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access        permit_mynetworks       reject_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport
virtual_alias_maps = hash:/etc/postfix/virtual

紀錄:

Sep 25 09:40:30 server1 postfix/smtpd[28285]: connect from mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:31 server1 postfix/smtpd[28285]: 7CA784EDB6: client=mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:31 server1 postfix/cleanup[28339]: 7CA784EDB6: message-id=<CAJjncucnGM532xhcn37VAwmwQoYEwOUfE_A33-oyJJH5PqPUcA@mail.gmail.com>
Sep 25 09:40:31 server1 postfix/qmgr[7593]: 7CA784EDB6: from=<[email protected]>, size=1813, nrcpt=1 (queue active)
Sep 25 09:40:32 server1 postfix/smtpd[28285]: disconnect from mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:32 server1 postfix/smtp[28593]: 7CA784EDB6: enabling PIX workarounds: disable_esmtp delay_dotcrlf for ...[...]]:25
Sep 25 09:40:33 server1 postfix/smtp[28593]: 7CA784EDB6: to=<[email protected]>, orig_to=<[email protected]>, relay=...[...]:25, delay=1.6, delays=0.45/0/0.42/0.73, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 98F729600E)
Sep 25 09:40:33 server1 postfix/qmgr[7593]: 7CA784EDB6: removed

答案1

從 mail.log 來看,您似乎想重寫來自遠端客戶端的電子郵件。 postfix rewrite 的預設設定可以防止這種情況發生。

摘自Postfix 重寫自述文件

Postfix 2.2 版可讓您選擇完全不重寫來自遠端 SMTP 用戶端的郵件標頭,或將此類郵件標頭中不完整的位址標記為無效。下面是它的工作原理:

  • Postfix 始終重寫來自本機 SMTP 用戶端和 Postfix sendmail 命令的郵件標頭,並將其自己的網域附加到不完整的位址。此local_header_rewrite_clients參數控制 Postfix 認為本地的 SMTP 用戶端(預設情況下,僅本地網路介面位址)。

  • remote_header_rewrite_domain當參數值為空(預設值)時,Postfix 從不重寫來自遠端 SMTP 用戶端的郵件標頭位址。

  • 否則,Postfix 會重寫來自遠端 SMTP 用戶端的郵件標頭,並將該remote_header_rewrite_domain值附加到不完整的位址。此功能可用於附加保留網域,例如“domain.invalid”,因此不完整的位址就不會被誤認為是本機位址。

因此,最簡單的解決方案是不要將參數保留remote_header_rewrite_domain為空值。您需要為此參數提供值,例如

remote_header_rewrite_domain = domain.invalid

或者你可以使用static:allon 參數local_header_rewrite_clients,這樣 postfix 就會將所有遠端客戶端視為本機客戶端。

local_header_rewrite_clients = static:all

來源:Postfix 位址重寫官方文檔

相關內容