我试图告诉 postfix 任何地址的所有邮件都应该转发到外部电子邮件地址。
我的 main.cf 包含以下条目
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = xshaunm-Q1532N
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = xshaunm-Q1532N, localhost.localdomain, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_alias_domains = xshaunm-Q1532N.pvt.lan
virtual_alias_maps = hash:/etc/postfix/virtual
我的 /etc/postfix/virtual 如下所示:
(.*) testaddress@gmail.com
然后我运行以下命令
后映射 /etc/postfix/virtual
重启后缀
/etc/init.d/postfix 重启
现在如果我运行命令
echo test | sendmail test@mydomain.com
它应该发送到 testaddress@gmail.com,但由于某种原因它发送到 test@mydomain.com,这是不正确的
如果我在 /etc/postfix/virtual 中列出确切的地址,如下所示,那么它可以工作,但是它需要捕获和转发数百个邮件地址,所以使用正则表达式会更好:
test@mydomain.com testaddress@gmail.com