除了本地用户到用户的电子邮件之外,postfix可以将所有出站电子邮件转发到中继主机吗?


1

在我的家庭Ubuntu框中,postfix配置为中继所有传出的电子邮件 outgoing.verizon.net。不幸的是,这包括本地用户到用户的电子邮件(例如,从本地cron作业到我,或从我到我自己),它们不需要在机外旅行。有没有办法调整我的配置(如下)所以本地电子邮件是在不离开我的机器的情况下交付的?

注意:我不运行邮件服务器(在端口25上),而是每隔五分钟运行一次fetchmail从IMAP服务器下载。

main.cf:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mycomputer.example.com
masquerade_domains = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.localdomain, localhost
relayhost = [outgoing.verizon.net]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtpd_sasl_auth_enable = no

Answers:


0

Postfix只会中继 non-local mails 到主机中指定的主机 relayhost。考虑本地域名;该域名必须列在 mydestination 参数。所以上市 example.commydestination 应该可以帮助您解决这个问题。

#/etc/postfix/main.cf
#...
mydestination = $myhostname, localhost.localdomain, localhost, example.com
#...

参考: Postfix文档

relayhost (default: empty)

The next-hop destination of non-local mail; overrides non-local domains in 
recipient addresses. This information is overruled with relay_transport, 
sender_dependent_default_transport_maps, default_transport, 
sender_dependent_relayhost_maps and with the transport(5) table. 

嗯......通过我发布的配置,用户名@ localhost被转发到relayhost。如果你的分析是正确的,那么不应该完全在本地处理username @ localhost,因为“localhost”列在mydestination中?
DanB

你可以发布postfix生成的maillog这样的邮件吗?
clement

啊,我不对劲。 username @ localhost确实在本地交付。然而,邮件只是“用户名”(例如,“echo foo | / usr / bin / mail username”),就像我通过电子邮件发送了username@blazemonger.com一样。
DanB

然后我猜你的 myorigin 具有 blazemonger.com。加 blazemonger.com 我的目的是在当地对待它。
clement

有用!谢谢你,谢谢你,谢谢你。
DanB
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.