问题描述
我正试图告诉后缀,所有发送到任何地址的邮件都应转发到外部电子邮件地址.
I am trying to tell postfix that all mails to any address should be forwarded to an external email address.
我的main.cf包含
My main.cf includes the entry for
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外观如下:
My /etc/postfix/virtual looks as follows:
(.*) [email protected]
然后我运行以下命令
postmap/etc/postfix/virtual
postmap /etc/postfix/virtual
重新启动后缀
/etc/init.d/postfix重新启动
/etc/init.d/postfix restart
现在,如果我运行命令
echo test | sendmail [email protected]
它应该发送到[email protected],但是由于某种原因,它会发送到[email protected],这是不正确的
it should deliver to [email protected], but for some reason it delivers to [email protected], which is incorrect
如果我按如下所示在/etc/postfix/virtual中列出确切的地址,那么它可以工作,但是需要捕获并转发数百个邮件地址,因此使用正则表达式会更好:
If i list the exact address in the /etc/postfix/virtual as follows then it works, but there are hundreds of mail addresses it needs to catch and forward, so a regular expression would be better:
[email protected] [email protected]
推荐答案
最终找到了答案.
此处列出后代.
将以下行添加到main.cf文件的末尾
Add the folowing line to the end of your main.cf file
vi /etc/postfix/main.cf
virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp
创建一个文件,其中列出了您要将所有邮件发送到的邮件地址
Create a file which lists the mail address you want all mails to be sent to
vi /etc/postfix/virtual-regexp
添加以下内容:
/.+@.+/ [email protected]
将其添加到邮图中
postmap /etc/postfix/virtual-regexp
您将需要添加一个虚拟文件.
you will need to add a virtual file.
touch /etc/postfix/virtual
现在将其添加到邮图中
postmap /etc/postfix/virtual
这篇关于postfix 2.9.6.1将所有邮件转发到外部邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!