我的 postfix + dovecot 安装出了问题。自 7 月以来,我的 catch-all 不再起作用。几天前我才意识到这个问题,因为我的一个朋友明确地向一个不存在的地址发送了一封邮件,但邮件没有到达。所以我翻看了一些日志,发现 catch-all 似乎不再起作用了。
查看邮件存储目录,我发现 Dovecot 为 @ 之前的每个“用户”创建了新邮箱,而不是将其发送到我的邮箱中。这些邮箱中最旧的邮箱来自 7 月,所以我认为那里出了问题。我已经一年没有更改过我的 postfix/dovecot 配置了。
编辑:最后一句话不正确。我今年早些时候从我的服务器中删除了 ClamAV。也许我搞砸了?
不过,我每次收到更新时都会安装。服务器正在运行 Debian Squeeze。
这是我的 postfix 配置:
~ > sudo postconf -n
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
mailbox_size_limit = 1099511627776
message_size_limit = 1073741824
mydestination = mail.mydomain.de
myhostname = mail.mydomain.de
mynetworks = 127.0.0.0/8
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
receive_override_options = no_address_mappings
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unknown_sender_domain, reject_rbl_client bl.spamcop.net, reject_rbl_client ix.dnsbl.manitu.net, permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
smtpd_use_tls = yes
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_transport = dovecot
virtual_uid_maps = static:5000
~ > sudo cat /etc/postfix/mysql-virtual_forwardings.cf
user = mail_admin
password = 123456
dbname = mail
query = SELECT destination FROM forwardings WHERE source='%s'
hosts = 127.0.0.1
~ > cat /etc/postfix/master.cf
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - - - - smtpd
#submission inet n - - - - smtpd
# -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
-o content_filter=spamassassin
#smtps inet n - - - - smtpd
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_client_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - - - - qmqpd
pickup fifo n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr fifo n - n 300 1 qmgr
#qmgr fifo n - - 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay unix - - - - - smtp
-o smtp_fallback_relay=
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop unix - n n - - pipe
# flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
#ifmail unix - n n - - pipe
# flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#bsmtp unix - n n - - pipe
# flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
#scalemail-backend unix - n n - 2 pipe
# flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
#mailman unix - n n - - pipe
# flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
# ${nexthop} ${user}
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
spamassassin unix - n n - - pipe
user=spamd argv=/usr/bin/spamc -f -e
/usr/sbin/sendmail -oi -f ${sender} ${recipient}
我的 mail.log 显示以下内容([电子邮件保护]应送达[电子邮件保护]):
Sep 5 16:27:18 lvps5-35-246-109 postfix/smtpd[7969]: connect from mail.other.com[194.XX.XX.77]
Sep 5 16:27:18 lvps5-35-246-109 postfix/smtpd[7969]: E24511027C1CE: client=mail.other.com[194.XX.XX.77]
Sep 5 16:27:18 lvps5-35-246-109 postfix/cleanup[7973]: E24511027C1CE: message-id=<[email protected]>
Sep 5 16:27:18 lvps5-35-246-109 postfix/qmgr[5915]: E24511027C1CE: from=<[email protected]>, size=4723, nrcpt=1 (queue active)
Sep 5 16:27:20 lvps5-35-246-109 postfix/pickup[5916]: A0D821027C1D3: uid=5001 from=<[email protected]>
Sep 5 16:27:20 lvps5-35-246-109 postfix/cleanup[7973]: A0D821027C1D3: message-id=<[email protected]>
Sep 5 16:27:20 lvps5-35-246-109 postfix/pipe[7975]: E24511027C1CE: to=<[email protected]>, relay=spamassassin, delay=1.8, delays=0.07/0.01/0/1.7, dsn=2.0.0, status=sent (delivered via spamassassin service)
Sep 5 16:27:20 lvps5-35-246-109 postfix/qmgr[5915]: E24511027C1CE: removed
Sep 5 16:27:20 lvps5-35-246-109 postfix/qmgr[5915]: A0D821027C1D3: from=<[email protected]>, size=5081, nrcpt=1 (queue active)
Sep 5 16:27:20 lvps5-35-246-109 postfix/pipe[7982]: A0D821027C1D3: to=<[email protected]>, relay=dovecot, delay=0.07, delays=0.05/0.01/0/0.01, dsn=2.0.0, status=sent (delivered via dovecot service)
Sep 5 16:27:20 lvps5-35-246-109 postfix/qmgr[5915]: A0D821027C1D3: removed
Sep 5 16:27:23 lvps5-35-246-109 postfix/smtpd[7969]: disconnect from other.com[194.XX.XX.77]
我的转发 MySQL 数据库如下所示:
mysql> describe forwardings;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| source | varchar(80) | NO | PRI | NULL | |
| destination | text | NO | | NULL | |
+-------------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> select * from forwardings;
+--------------+-----------------------+
| source | destination |
+--------------+-----------------------+
| @mydomain.de | [email protected] |
+--------------+-----------------------+
Dovecot 日志文件显示 postfix 无法解析正确的目的地:
2013-09-05 16:27:20 deliver([email protected]): Info: msgid=<[email protected]>: saved mail to INBOX
从 postfix 记录 MySQL 查询:
130905 16:09:34 68 Query SELECT domain AS virtual FROM domains WHERE domain='other.com'
68 Query SELECT domain AS virtual FROM domains WHERE domain='mydomain.de'
69 Query SELECT destination FROM forwardings WHERE source='[email protected]'
70 Query SELECT email FROM users WHERE email='[email protected]'
69 Query SELECT destination FROM forwardings WHERE source='@mydomain.de'
最后一行表示 postfix 尝试解析不存在的地址。手动执行查询:
mysql> SELECT destination FROM forwardings WHERE source='@mydomain.de';
+-----------------------+
| destination |
+-----------------------+
| [email protected] |
+-----------------------+
1 row in set (0.00 sec)
一切似乎都已准备就绪,应该可以正常工作。但事实并非如此。有人知道是什么原因导致了这种行为吗?
感谢您阅读本文;)
问候,塞巴斯蒂安
答案1
在您的 中,main.cf
您有receive_override_options = no_address_mappings
。这将禁用 catch-all。删除此行以再次启用它。
receive_override_options
在启用了 catch-all 功能的 clamav 内容过滤器之后,您对 postfix 实例的配置可能有所不同。