未定义地址的后缀、虚拟别名和包罗万象

Kon*_*eld 8 postfix alias

在 Postfix 2.10.2 中,我设置了多个域和多个虚拟别名来为本地用户分配邮件地址。只要我不添加包罗万象,它就可以正常工作。

在我使用虚拟别名之前,我定义了一个包罗万象的东西

local_recipient_maps =
luser_relay = catchall
Run Code Online (Sandbox Code Playgroud)

但由于我需要整理来自不同域的邮件地址,我不得不使用虚拟别名。

现在postfix.org说我应该这样做,我做到了:

/etc/postfix/main.cf:

virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual
Run Code Online (Sandbox Code Playgroud)

/etc/postfix/虚拟:

postmaster@example.com account1
info@example.com       account1
sales@example.com      account2
@example.com         catchall
Run Code Online (Sandbox Code Playgroud)

但是如果我这样做,catchall 地址会抓取我所有的邮件,而不仅仅是发送到未明确定义的地址的邮件。为什么会这样,我该如何更改它?

我做了 postmap virtual 并重新启动了 Postfix。日志中没有错误,它只是将交付记录到 catchall 地址。并且有一个警告“不要在 mydestination 和 virtual_alias_domains 中列出域 example.com”,但我没有这样做!我什至没有 mydestination 指令。(下面的配置中有一个,但我在 NickW 建议之后添加了它。)

这是我的完整配置:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot.conf -m "${EXTENSION}"
mailbox_size_limit = 0
mydestination = $myhostname
myhostname = mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/dovecot-auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = reject_unknown_sender_domain
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/dovecot/dovecot.pem
smtpd_tls_key_file = /etc/dovecot/private/dovecot.pem
smtpd_tls_mandatory_ciphers = medium
smtpd_tls_mandatory_protocols = SSLv3, TLSv1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
virtual_alias_domains = $myhostname, myotherdomain.com
virtual_alias_maps = hash:/etc/postfix/virtual
Run Code Online (Sandbox Code Playgroud)

小智 6

如果您在虚拟别名中包含捕获所有电子邮件地址,那么它将起作用。

main.cf

 virtual_alias_maps = hash:/etc/postfix/virtual
Run Code Online (Sandbox Code Playgroud)

virtual

user1@example.com           user1@example.com
user2@example.com           user2@example.com
...
catchall@example.com        catchall@example.com
@example.com                catchall@example.com
Run Code Online (Sandbox Code Playgroud)


Kon*_*eld 5

所以,我想通了。有些人建议全能必须在虚拟别名文件之上,但我之前尝试过,但没有帮助(尽管我发现该解决方案非常合乎逻辑)。

有效的是:

  1. 设置mydestination=localhost(不是$myhostname
  2. 在虚拟别名文件的顶部添加 catchall: @domain.com catchall-account@localhost
  3. 在下面添加所有其他虚拟别名: contact@domain.com contact@localhost

该示例假设您有名为catchall-account和 的UNIX 用户contact。发送至 contact@domain.com 的邮件将递送至联系人​​用户,而所有其他邮件将递送至全能帐户。

也许这在所有情况下都不是必需的,但在我的特殊情况下,我想使用一个帐户来保存某些地址的邮件,但直接发送到该帐户的邮件最终应该是万能的。

毕竟,看起来 Postfix 并没有通过从上到下的虚拟别名的方式工作,而且包罗万象有一些特殊的优先级。如果有人实际上能够解释这种行为,我会很高兴有进一步的评论。