我有一个包含数百个电子邮件地址的域名。我们正在将托管迁移到多个 ISPConfig 服务器。我的问题是,如果有人发送电子邮件到[email protected]
第一个服务器上,并且该电子邮件不存在,我该如何告诉 postfix 不要回复
550 5.1.1 收件人地址被拒绝:虚拟邮箱表中的用户未知(回复 RCPT TO 命令)
而是将邮件转发到该邮件所在的MX第二服务器。
我曾尝试像这样扩展我的 postfix main.cf 配置:
transport_maps = hash:/var/lib/mailman/data/transport-mailman,代理:mysql:/etc/postfix/mysql-virtual_transports.cf,哈希:/etc/postfix/transport
/etc/postfix/transport
看起来像这样:
中继:[服务器的 IPv4 地址]
但它没有起作用。
我的配置是:
address_verify_virtual_transport = $virtual_transport
propagate_unmatched_extensions = canonical, virtual
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps
relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf
relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf
sender_bcc_maps = proxy:mysql:/etc/postfix/mysql-virtual_outgoing_bcc.cf
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf
smtpd_sender_login_maps = proxy:mysql:/etc/postfix/mysql-virtual_sender_login_maps.cf
smtpd_sender_restrictions = check_sender_access regexp:/etc/postfix/tag_as_originating.re , permit_mynetworks, permit_sasl_authenticated, check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, check_sender_access regexp:/etc/postfix/tag_as_foreign.re
transport_maps = hash:/var/lib/mailman/data/transport-mailman, hash:/etc/postfix/transport, proxy:mysql:/etc/postfix/mysql-virtual_transports.cf
unknown_virtual_alias_reject_code = 550
unknown_virtual_mailbox_reject_code = 550
virtual_alias_address_length_limit = 1000
virtual_alias_domains =
virtual_alias_expansion_limit = 1000
virtual_alias_maps = hash:/var/lib/mailman/data/virtual-mailman, proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, proxy:mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_alias_recursion_limit = 1000
virtual_delivery_slot_cost = $default_delivery_slot_cost
virtual_delivery_slot_discount = $default_delivery_slot_discount
virtual_delivery_slot_loan = $default_delivery_slot_loan
virtual_delivery_status_filter = $default_delivery_status_filter
virtual_destination_concurrency_failed_cohort_limit = $default_destination_concurrency_failed_cohort_limit
virtual_destination_concurrency_limit = $default_destination_concurrency_limit
virtual_destination_concurrency_negative_feedback = $default_destination_concurrency_negative_feedback
virtual_destination_concurrency_positive_feedback = $default_destination_concurrency_positive_feedback
virtual_destination_rate_delay = $default_destination_rate_delay
virtual_destination_recipient_limit = $default_destination_recipient_limit
virtual_extra_recipient_limit = $default_extra_recipient_limit
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
virtual_initial_destination_concurrency = $initial_destination_concurrency
virtual_mailbox_base = /var/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_lock = fcntl, dotlock
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_minimum_delivery_slots = $default_minimum_delivery_slots
virtual_minimum_uid = 100
virtual_recipient_limit = $default_recipient_limit
virtual_recipient_refill_delay = $default_recipient_refill_delay
virtual_recipient_refill_limit = $default_recipient_refill_limit
virtual_transport = dovecot
virtual_transport_rate_delay = $default_transport_rate_delay
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
postconf |grep smtpd_recipient
smtpd_recipient_limit = 1000
smtpd_recipient_overshoot_limit = 1000
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf
答案1
transport_map 是确定如何传递的方法,但它在“ smtpd_reject_unlisted_recipient”或 smtpd_recipient_restrictions = rejection_unlisted_recipient, ... 之后开始生效。
因此,您还需要为其他邮件服务器中的收件人添加验证,而不仅仅是当前服务器中的用户。
您在 smtpd_recipient_restrictions = .... check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf,... 中还必须通过某种方式在其他邮件服务器中找到有效用户列表。要么直接使用 SQL 查找其他邮件服务器,要么将列表导出到映射文件(定期使用 cron),这样即使其他邮件服务器关闭也不会失败。就我而言,我使用 ldap 查找有效用户,并创建一个包含所有有效收件人邮件地址列表的本地文件。您也可以使用相同的方法创建传输映射 + 一些脚本在每个邮件地址后添加 smtp:[ipaddress.othermailserver]
您可以以调试模式(-D)和/或详细日志记录(-vvv)启动 postfix 来查看它如何评估拒绝。
也可以看看 http://www.postfix.org/postconf.5.html#smtpd_reject_unlisted_recipient
答案2
您今天如何验证收到的邮件的邮件地址,本地 Linux 用户或 Ldap/SQl/xyz?您可以分享一下吗
sudo postconf |grep virtual
sudo postconf |grep 收件人