我使用 Postfix 2.9.6、DSpam 3.10.1 和 Dovecot 2.1.7 接收邮件时遇到以下情况:
Incoming Mail -> SMTP -> LMTP -> DSpam (as daemon) -> LMTP -> Dovecot
我有虚拟域名和虚拟邮箱。到目前为止一切正常。
现在,指向外部域的(虚拟?)别名出现了问题。假设我有以下虚拟域:
virtualdomain1.com
virtualdomain2.com
我负责处理邮件。服务器本身运行于
mydomain.com
如果我现在添加一个指向外部域的别名,例如:
[email protected] -> [email protected]
然后(据我所知,日志显示),DSpam 检查邮件,通过 LMTP 将其传递给 Dovecot,而 Dovecot 拒绝了该邮件,因为[电子邮件保护]是未知的(当然是真的)。
那么,如何正确设置才能处理虚拟域的别名?如果可能的话,我还想检查收到的邮件中的虚拟别名。
收到消息的日志[电子邮件保护]是:
postfix/smtpd[23910]: connect from xxx.anyhost.com[1.2.3.4]
postfix/smtpd[23910]: NOQUEUE: filter: RCPT from xxx.anyhost.com[1.2.3.4]: <[email protected]>: Recipient address triggers FILTER lmtp:unix:/dspam/dspam.sock; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<anyhost.com>
postfix/smtpd[23910]: D91D0771AF70: client=xxx.anyhost.com[1.2.3.4]
postfix/cleanup[23917]: D91D0771AF70: message-id=<[email protected]>
postfix/smtpd[23910]: disconnect from xxx.anyhost.com[1.2.3.4]
postfix/qmgr[23278]: D91D0771AF70: from=<[email protected]>, size=1030, nrcpt=1 (queue active)
dovecot: lmtp(23920): Debug: none: root=, index=, control=, inbox=, alt=
dovecot: lmtp(23920): Connect from local
dovecot: lmtp(23920): Debug: Loading modules from directory: /usr/lib/dovecot/modules
dovecot: lmtp(23920): Debug: Module loaded: /usr/lib/dovecot/modules/lib90_sieve_plugin.so
dovecot: auth-worker(23921): mysql(127.0.0.1): Connected to database postfixadmin
dspam[9421]: Got error 550 in response to RCPT TO: 550 5.1.1 <[email protected]> User doesn't exist: [email protected]#015
dovecot: auth-worker(23921): sql([email protected]): unknown user
dovecot: lmtp(23920): Debug: auth input:
dovecot: lmtp(23920): Disconnect from local: Client quit (in RCPT TO)
postfix/lmtp[23918]: D91D0771AF70: to=<[email protected]>, orig_to=<[email protected]>, relay=mail.mydomain.com[/dspam/dspam.sock], delay=0.98, delays=0.47/0.01/0/0.5, dsn=5.3.0, status=bounced (host mail.mydomain.com[/dspam/dspam.sock] said: 530 5.3.0 <[email protected]> Fatal: 550 5.1.1 <[email protected]> User doesn't exist: [email protected] (in reply to end of DATA command))
postfix/cleanup[23917]: 149CB771AF72: message-id=<[email protected]>
postfix/bounce[23923]: D91D0771AF70: sender non-delivery notification: 149CB771AF72
postfix/qmgr[23278]: 149CB771AF72: from=<>, size=3182, nrcpt=1 (queue active)
postfix/qmgr[23278]: D91D0771AF70: removed
postfix/smtp[23925]: 149CB771AF72: to=<[email protected]>, relay=mx.mydomain.com[1.2.3.5]:25, delay=3.9, delays=0.26/0.01/0.09/3.6, dsn=2.0.0, status=sent (250 OK id=1YY9Ne-0007eJ-Hp)
postfix/qmgr[23278]: 149CB771AF72: removed
postfix main.cf:smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
readme_directory = no
# BECAUSE we use Dovecot for authentication we also use its certificates
smtpd_tls_cert_file=/etc/dovecot/dovecot.pem
smtpd_tls_key_file=/etc/dovecot/private/dovecot.pem
smtpd_use_tls=yes
smtpd_tls_auth_only = yes
#Handing off local delivery to Dovecot's LMTP, and telling it where to store mail
virtual_transport = lmtp:unix:private/dovecot-lmtp
#Virtual domains, users, and aliases
virtual_mailbox_domains = proxy:mysql:$config_directory/mysql_virtual_domains_maps.cf
virtual_mailbox_maps =
proxy:mysql:$config_directory/mysql_virtual_mailbox_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_mailbox_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_catchall_maps.cf
virtual_alias_maps =
proxy:mysql:$config_directory/mysql_virtual_alias_maps.cf,
proxy:mysql:$config_directory/mysql_virtual_alias_domain_maps.cf
virtual_mailbox_limit = proxy:mysql:$config_directory/mysql_virtual_mailbox_limit_maps.cf
myhostname = mail.me.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost, $myhostname
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 1000000000
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
#Enabling SMTP for authenticated users, and handing off authentication to Dovecot
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination,
check_recipient_access pcre:/etc/postfix/dspam_filter_access,
permit
dspam_filter_access 文件:
/./ FILTER lmtp:unix:/dspam/dspam.sock
最后说明一下:如果我评论此行
#check_recipient_access pcre:/etc/postfix/dspam_filter_access,
一切正常,但当然没有垃圾邮件检查。
答案1
在您目前的上述设置中,dovecot 和 dspam 都无法将您的电子邮件重新路由到正确的目的地。尤其是对于 dovecot,它只能根据域配置接受电子邮件。
解决方案是更改您的dspam
设置发送电子邮件返回到 postfix扫描后将其发送到 dovecot。使用此设置,扫描后 postfix 路由引擎将重新路由您的电子邮件
- 如果收件人地址指向外部域,则发送到外部邮件服务器
- 到 dovecot,如果收件人地址与您的虚拟域匹配
换句话说
[ Outside ] --smtp--> [ Postfix ] --lmtp--> [ dspam ] --smtp--> [ postfix ] --> dovecot (if localdomain) or another mail server (if external domain)
您可以像 dspam 设置一样进行配置本教程. 步骤摘要
- 在 master.cf 中添加第二个 postfix smtpd 监听器,例如 localhost:10026
- 您可以使用 content_filter 参数来代替将
dspam_filter_access
电子邮件发送到 dspam - 更改配置交付{主机、端口、协议}在 DSPAM 中将第二个 smtpd 添加到 postfix
- 禁用地址映射(
no_address_mappings
)content_filter 和第二个 smtpd 中的另一个限制
答案2
您可以完全绕过 DSPAM 对外部别名的检查。
Incoming Mail -> SMTP -> External address
删除 check_recipient_access 行并将 dspam 设置为默认的 virtual_transport:
virtual_transport = lmtp:unix:/dspam/dspam.sock
节省资源并避免一些疯狂的本地弹跳。电子邮件很可能会在外部目的地被检查为垃圾邮件…… ;-)