Postfix 中继到或从我的域,但不中继到或从另一个域

Postfix 中继到或从我的域,但不中继到或从另一个域

我有几个 postfix 服务器,我用它们从 webforms 发送电子邮件,我希望能够从外部域向我的域发送电子邮件,从我的域向我的域发送电子邮件,以及从我的域向外部域发送电子邮件。

我不想从外部域发送到外部域。

mynetworks 本身似乎可以实现完整的开放中继(从任意到任意),而这并不是我想要的。

内部域 = example.com,example.org 外部域 = yahoo.com

从内部到任何 = 允许

期望结果:

mail from: [email protected] < 2.1.0 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 2.1.5 OK

实际结果:

rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 454 4.7.1 Relay Access Denied

从任意到仅限内部

期望结果:

mail from: [email protected] < 2.1.0 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 454 4.7.1 Relay Access Denied

实际结果:

mail from: [email protected] < 2.1.0 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 2.1.5 OK
rcpt to: [email protected] < 454 4.7.1 Relay Access Denied

答案1

当我经历每一个场景时我都明白了!

/etc/postfix/main.cf

mynetworks = 127.0.0.0/8, 10.0.0.0/8
relay_domains = example.com, example.org
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/sender_access,reject_unknown_sender_domain,reject_unknown_recipient_domain,permit
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access,check_recipient_access hash:/etc/postfix/sender_access,reject_unknown_sender_domain,reject_unknown_recipient_domain,reject

/etc/postfix/sender_access

example.com  OK
example.org  OK

相关内容