邮件服务器在本地投递时出现“虚拟邮箱表中的用户未知”的情况,从而创建邮件账户

邮件服务器在本地投递时出现“虚拟邮箱表中的用户未知”的情况,从而创建邮件账户

我正在运行带有虚拟域的旧版 Postfix 和 Courier 邮件服务器。我最近遇到过这种情况:向不存在的邮箱进行本地投递(使用 Webmail)会导致创建包含/var/vmail/domain/notexistinguser电子邮件的实际邮箱。我认为邮件应该退回给发件人。来自外部系统的电子邮件确实会触发退回。

我不太确定这个问题是否与 Postfix、Courier 或我服务器上运行的其他服务有关。因此,我愿意发送您可能需要的任何配置、日志等,以帮助我解决问题。

一些额外的信息

输出postconf -n(出于隐私考虑,主机名已被替换):

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
anvil_rate_time_unit = 43200
append_dot_mydomain = no
biff = no
body_checks = regexp:/etc/postfix/body_checks
bounce_queue_lifetime = 1
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
content_filter = amavis:[127.0.0.1]:10024
header_checks = regexp:/etc/postfix/header_checks
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
maximal_queue_lifetime = 1
message_size_limit = 0
mime_header_checks = regexp:/etc/postfix/mime_header_checks
mydestination = example.com, localhost, localhost.localdomain
myhostname = example.com
mynetworks = 127.0.0.0/8 [::1]/128
myorigin = /etc/mailname
nested_header_checks = regexp:/etc/postfix/nested_header_checks
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
recipient_delimiter = +
relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_client_connection_count_limit = 5
smtpd_client_connection_rate_limit = 1000
smtpd_client_message_rate_limit = 1000
smtpd_client_recipient_rate_limit = 1000
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
smtpd_error_sleep_time = 2s
smtpd_hard_error_limit = 20
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination, reject_non_fqdn_sender, check_policy_service inet:127.0.0.1:10023, reject_rbl_client cbl.abuseat.org, reject_rbl_client bl.spamcop.net, reject_rbl_client zen.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf
smtpd_soft_error_limit = 10
smtpd_tls_CAfile = /etc/ssl/local/ca-certs
smtpd_tls_cert_file = /etc/ssl/local/certificate
smtpd_tls_key_file = /etc/ssl/local/key
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
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 = /var/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 = maildrop
virtual_uid_maps = static:5000

从命令行发送邮件会在邮件日志中显示以下内容(为保护隐私,主机名和域名已替换):

Jan 26 13:33:01 myhost postfix/smtpd[25786]: 0F29E41134A62: client=localhost[127.0.0.1]
Jan 26 13:33:01 myhost postfix/cleanup[8531]: 0F29E41134A62: message-id=<[email protected]>
Jan 26 13:33:01 myhost postfix/qmgr[26331]: 0F29E41134A62: from=<[email protected]>, size=755, nrcpt=1 (queue active)
Jan 26 13:33:01 myhost amavis[18765]: (18765-09) Passed CLEAN, <[email protected]> -> <[email protected]>, Message-ID: <[email protected]>, mail_id: jgU7IihKWNMv, Hits: 1.044, size: 310, queued_as: 0F29E41134A62, 3470 ms
Jan 26 13:33:01 myhost postfix/smtp[14895]: A808940E253C9: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=3.5, delays=0.04/0/0/3.5, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=18765-09, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 0F29E41134A62)
Jan 26 13:33:01 myhost postfix/qmgr[26331]: A808940E253C9: removed
Jan 26 13:33:02 myhost postfix/pipe[10437]: 0F29E41134A62: to=<[email protected]>, relay=maildrop, delay=1.3, delays=0.09/0/0/1.2, dsn=2.0.0, status=sent (delivered via maildrop service)
Jan 26 13:33:02 myhost postfix/qmgr[26331]: 0F29E41134A62: removed

查看 /var/vmail/example.com 发现该用户是在同一时间戳创建的。在发送测试电子邮件之前,该用户并不存在。

drwx------   5 vmail vmail    61 2015-01-26 13:33 unknown01

答案1

一个解决方法是将传递方法的配置从(发送)邮件更改为使用本地主机的 SMTP。

  • 在 roundcube 上,你可以使用以下命令更改配置

    $config['smtp_server'] = 'localhost';
    
  • 在 Squirrelmail 上,使用conf.pl脚本。输入Server Settings然后在选项中选择 SMTP,Sendmail or SMTP配置服务器为 localhost,端口为 25。


这种情况之所以会发生,是因为在发送电子邮件时,postfix 负责检查用户的存在。Maildrop 本身无法为您执行用户存在检查。不幸的是,此检查是在电子邮件通过 SMTP 发送不是mail命令。原因是mail命令仅在本地主机中的某些进程中调用,因此 postfix 会信任它。

打开/关闭用户存在性检查的具体选项是smtpd_reject_unlisted_recipient。您可以阅读以下文档官方文档

参考:此主题

相关内容