我正在设置 postfix 将发送到域的电子邮件转发到外部电子邮件地址。例如,当我在[电子邮件保护]它会自动发送到[电子邮件保护]。这很有效,只是当我收到电子邮件时,它显示收件人位于[电子邮件保护]代替[电子邮件保护]。
我知道这是可以做到的,因为当我使用廉价托管公司的网络面板转发电子邮件时,效果很好。那么,如何让 postfix 保留收件人地址,即使它被转发到另一个地址?
我的配置:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_command =
mailbox_size_limit = 0
mydestination = mydomain.com, localhost.localdomain, localhost
myhostname = mx1.mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
recipient_delimiter = +
relayhost = [smtp.mandrillapp.com]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_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
需要明确的是,当我在转发的地址收到电子邮件时,我仍然希望它显示收件人:地址具有原始收件人(@mydomain.com)。
答案1
看起来你使用了这个参数
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical
提供邮件转发。默认情况下规范地址映射将重写信头和信封地址。因此,禁用信头重写,您有两个选择
配置
recipient_canonical_classes
仅recipient_canonical_maps
影响信封地址。recipient_canonical_classes = envelope_recipient
使用
virtual_alias_maps
专为信封地址映射而设计的,无需触及标题。
优先virtual_alias_maps
选择在这种情况下,您可以使用它来执行一对多映射。参数recipient_canonical_maps
仅支持一对一映射。