迄今为止

迄今为止

迄今为止

这个答案很有帮助

https://serverfault.com/a/793202/604224

问题

我一直在 virtualbox 中配置虚拟邮箱进行测试,但它似乎接受所有用户,甚至是未在 virtual_mailbox_maps 中定义的用户,尽管清除了 mydestination(因此它不会被处理为本地邮件)并添加了一些 smtpd_recipient_restrictions

当我测试将邮件发送到不存在的邮箱(但退出域)时,例如

echo "This is the body of the email" | mail -s "This is the subject line" [email protected]

/var/log/maillog 显示

postfix/qmgr[14474]: E890D1883308: from=<[email protected]>, size=470, nrcpt=1 (queue active)
E890D1883308: to=<[email protected]>, relay=myhook, delay=0.6, delays=0.03/0.01/0/0.56, dsn=2.0.0, status=sent (delivered via myhook service)

这意味着它被接受并被发送到虚拟传输而没有被拒绝。

希望能得到一些帮助

配置

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
mydestination =
mydomain = laravel8.test
myhostname = laravel8.test
mynetworks_style = class
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
shlib_directory = /usr/lib64/postfix
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_security_level = may
smtpd_recipient_restrictions = reject_unknown_recipient_domain reject_unauth_destination reject_unverified_recipient
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-email2email.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = myhook:dummy

mysql 文件配置

virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-email2email.cf

user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT CONCAT(account, '@', domain) FROM mailbox WHERE account='%u' AND domain='%d'

virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf

user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT domain FROM mailbox WHERE domain='%s' LIMIT 1

virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf

user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT 1 FROM mailbox WHERE account='%u' AND domain='%d'

答案1

问题在于此配置行

smtpd_recipient_restrictions = reject_unknown_recipient_domain reject_unauth_destination reject_unverified_recipient

您必须检查限制中的收件人地址。查看 check_recipient_access 配置参数:

smtpd_recipient_restrictions = 
    reject_unknown_recipient_domain,
    reject_unauth_destination,
    reject_unverified_recipient,
    check_recipient_access mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf

相关内容