后缀:只接收来自特定域的电子邮件?

我如何设置Postfix,以便它只接收来自特定域的电子邮件

在我的服务器上有一个特定的电子邮件帐户,我只希望能够接收从txt.att.net,text.wireless.alltel.com和mms.alltel.net转发的电子邮件。 任何其他邮件转发到这个帐户应该被反弹回发件人。

这取决于你想限制它。 我不确定那些是你正在讨论的邮件中继还是发送地址。

发送地址

您可以在适当的smtpd _ * _限制内使用check_sender_access指令。 通常情况下,最好的做法是在收件人限制内应用所有发件人,主人检查等(即在客户端发送'RCPT到:'后)

例如只允许来自发件人@ gmail.com和@ hotmail.com的邮件…

将smtpd_recipient_restrictions设置为以下内容:

smtpd_recipient_restrictions = check_sender_access hash:/etc/postfix/access, reject 

现在/ etc / postfix / access应该是这样的forms:

 gmail.com OK hotmail.com OK 

使用postmap哈希:/ etc / postfix / access来创build哈希表。

中继主机名或IP

 smtpd_recipient_restrictions = check_client_access hash:/etc/postfix/client_access, reject 

client_access的格式类似:

 host.name.of.system.com OK ip.addr.of.system OK 

读你的日志

以下是我的mail.log中的示例消息的完整摘录。 我选了一条消息,得到了队列ID – 31AF4761F3。 它将位于邮件的标题以及邮件日志文件中。

 $ grep 31AF4761F3 /var/log/mail.log Sep 4 09:30:38 cutoffs postfix/smtpd[7912]: 31AF4761F3: client=russian-caravan.cloud9.net[wxyz] Sep 4 09:30:38 cutoffs postfix/cleanup[7915]: 31AF4761F3: message-id=<007B93C54F154113B36026A22D5E0106@gaby> Sep 4 09:30:38 cutoffs postfix/qmgr[19172]: 31AF4761F3: from=<[email protected]>, size=4225, nrcpt=1 (queue active) Sep 4 09:30:39 cutoffs postfix/pipe[7916]: 31AF4761F3: to=<XXXX@XXXX>, relay=spamassassin, delay=1.4, delays=0.19/0.01/0/1.3, dsn=2.0.0, status=sent (delivered via spamassassin service) Sep 4 09:30:39 cutoffs postfix/qmgr[19172]: 31AF4761F3: removed 

您可以在第一行看到,我们有client = russian-caravan.cloud9.net(这是发送邮件给postfix邮件列表的邮件服务器),IP地址在括号内。 您可以使用访问文件中的主机名或IP,但请记住,如果他们有多个邮件中继,或者更改邮件中继,则需要弄清楚。

菲尔的答案是好的,除了一个细节。 不要在/ etc / postfix / access或/ etc / postfix / client_access的RHS上使用“OK”。 这使得您的邮件服务器对于声称从@ gmail.com或@ hotmail.com(访问)发送邮件或者在client_access中允许的特定主机的任何人都是部分开放中继。 这不仅仅是允许他们发送邮件给你的系统中的特定用户,它允许他们通过你的邮件中继给任何系统上的任何用户。

而是使用“permit_auth_destination”。 允许他们发送到您的本地域,或任何您configuration为中继,但不是任何的任何领域。

例如

在/ etc /后缀/访问:

 gmail.com permit_auth_destination
 hotmail.com permit_auth_destination

/等/后缀/ client_access:

 host.name.of.system.com permit_auth_destination
 ip.addr.of.system permit_auth_destination

即使一切都是完美configuration,在后缀访问规则中使用“OK”是一个不好的习惯。 有时你真的需要它,但是默认情况下你的习惯应该是使用“permit_auth_destination”。

基于以下链接:[ http://www.postfix.org/RESTRICTION_CLASS_README.html#internal%5D [2 ]

我的configuration:

/etc/postfix/main.cf中

  smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/protected_destinations,permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_restriction_classes = insiders_only insiders_only = check_sender_access hash:/etc/postfix/insiders, reject 

在/ etc /后缀/知情人

  mydomain.com OK otherdomain.com OK [email protected] OK 

/等/后缀/ protected_destinations

 restricted_email@ insiders_only 

然后

  postmap /etc/postfix/insiders postmap /etc/postfix/protected_destinations /etc/init.d/postfix restart 

这种设置只允许来自/ etc / postfix / insiders对象的传入电子邮件,并且只影响保存在文件protected_destinations中的地址,而不影响全局系统,因此所有其他用户都可以收到传入的邮件。 请注意,它可以是域名和/或电子邮件地址。

restricted_email @ insiders_only行覆盖服务器中的所有域。 我只持有我的服务器上的本地用户,我需要把“@”放在restricted_email的末尾,以便与我想要的所有restricted_email @域一起工作。