我试图实现的是,任何发送到[email protected]电子邮件都会被重写为[email protected]送到[email protected] 。
canonical_maps和virtual_alias_maps都可以传递给备用收件人。 当我阅读文档时,它告诉我用canonical_maps cleanup会完全重写。
但是,实际上电子邮件仍然具有原始收件人的地址。 所以当在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
从mail.log中,看起来像要从远程客户端重写电子邮件。 后缀重写的默认设置防止发生这种情况。
摘自Postfix重写README
Postfix 2.2版本可以select不重写来自远程SMTP客户端的邮件标题,或者将这些邮件标题中的不完整地址标记为无效。 下面是它的工作原理:
Postfix总是重写本地SMTP客户端和Postfix sendmail命令的邮件头,并将自己的域追加到不完整的地址。
local_header_rewrite_clients参数控制Postfix认为本地的SMTP客户端(默认只有本地networking接口地址)。当
remote_header_rewrite_domain参数值为空(默认设置)时,Postfix从不重写远程SMTP客户端的邮件头地址。否则,Postfix将重写来自远程SMTP客户端的邮件头,并将
remote_header_rewrite_domain值附加到不完整的地址。 这个function可以用来附加一个保留的域名,比如“domain.invalid”,这样不完整的地址就不会被误认为是本地地址。
所以,最简单的解决scheme是不要将参数remote_header_rewrite_domain保留为空值。 您需要为此参数提供值,例如
remote_header_rewrite_domain = domain.invalid
或者你可以在参数local_header_rewrite_clients上使用static:all ,这样postfix将把所有的远程客户端视为本地的。
local_header_rewrite_clients = static:all
来源: Postfix地址重写的官方文档