Postfix の受信者を完全に変更する

Postfix の受信者を完全に変更する

私が実現しようとしているのは、 に届くすべての電子メール[email protected]が に書き換えられ[email protected]、 に配信されることです[email protected]

どちらもcanonical_maps代替virtual_alias_maps受信者に配達するために機能します。ドキュメントcanonical_mapsを使用すると、cleanup完全な書き換えが行われることがわかります。

しかし、実際には、メールにはto元の受信者の情報が残っています。そのため、ボブのメールボックスにあるメールを見ると、ジョー宛のメールであることがわかります。

どういうわけか、ここで何かが欠けているような気がします。

構成:

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 書き換えのデフォルト設定では、これが起こりません。

抜粋Postfix 書き換え README

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:allパラメータを使用するlocal_header_rewrite_clientsと、Postfix はすべてのリモート クライアントをローカルとして扱うようになります。

local_header_rewrite_clients = static:all

ソース:Postfix アドレス書き換えの公式ドキュメント

関連情報