POSTFIX smtpd 中继取决于发送者

POSTFIX smtpd 中继取决于发送者

我在服务器上使用 Postfix为 以及托管在服务器上的其他域、 和mx1.domain1.com转发电子邮件( )。此外,还代表另一台服务器转发电子邮件()。一切都很顺利。domain1.comdomain2.netdomain3.orgdomain1.commx1.domain1.comoffsite.domain1.com

我的main.cf样子是这样的:

smtpd_sender_login_maps = hash:/etc/postfix/controlled_envelope_senders
smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service unix:private/policy-spf, check_policy_service inet:127.0.0.1:10023, permit
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_relay_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service unix:private/policy-spf, check_policy_service inet:127.0.0.1:10023, permit

myorigin = /etc/mailname
mydestination = mx1.domain1.com, domain1.com, localhost

virtual_alias_domains = domain2.net, domain3.org
virtual_alias_maps = hash:/etc/postfix/virtual

这是我的/etc/postfix/controlled_envelope_senders

#envelope sender        owners (SASL login names)
@domain1.com        user1
@offisite.domain1.com   user1
@domain2.net            user1, user2
@domain3.org        user1, user3

这是我的/etc/postfix/virtual

[email protected]  username1
[email protected]  username2

我想要实现以下目标。我想使用 mx1.domain1.com 上的 POSTFIX 实例来中继消息,domain4.ca但使用 的 SMTP 服务器domain4.ca,我已对其进行了身份验证。

我试图通过修改以下内容来实现此目的main.cf

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
relayhost =
relay_domains = domain4.ca

但是,无论我做什么,都会出现以下错误:

Dec 12 18:24:48 vserver-fra01 postfix/smtps/smtpd[146379]: connect from unknown[1.2.3.4]
Dec 12 18:24:48 vserver-fra01 postfix/smtps/smtpd[146379]: Anonymous TLS connection established from unknown[1.2.3.4]: TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
Dec 12 18:24:49 mx1 postfix/smtps/smtpd[146379]: NOQUEUE: reject: RCPT from unknown[1.2.3.4]: 553 5.7.1 <[email protected]>: Sender address rejected: not owned by user xyz; from=< [email protected] > to=<[email protected]> proto=ESMTP helo=<[2.3.4.5]>
Dec 12 18:24:49 mx1 postfix/smtps/smtpd[146379]: lost connection after RCPT from unknown[1.2.3.4]
Dec 12 18:24:49 mx1 postfix/smtps/smtpd[146379]: disconnect from unknown[1.2.3.4] ehlo=1 auth=1 mail=1 rcpt=0/1 commands=3/4

如何配置 POSTFIXmx1.domain1.com以进行中继domain4.ca并使用 SMTP 服务器domain4.ca

解决方案:

我忽略了 中的一行master.cf,它“规定”谁有权使用 SMTP 服务;它引用了/etc/postfix/virtual

smtps     inet  n       -       y       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_sasl_security_options=noanonymous,noplaintext
  -o smtpd_sasl_local_domain=$myhostname,localhost
  -o smtpd_sasl_tls_security_options=noanonymous
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o smtpd_sender_login_maps=hash:/etc/postfix/virtual

因此,解决方案是添加domain4.ca/etc/postfix/virtual表中。

[email protected]   username1

答案1

您需要使用交通地图

  1. transport_maps = hash:/etc/postfix/transport在 main.cf 中
  2. 创建一个文件,例如 /etc/postfix/transport,其中包含以下内容 domain4.ca [smtp.domain4.ca]:587(一行)
  3. postmap /etc/postfix/transport
  4. 重新加载 postfix

相关内容