阻止向 exim 中的某些用户发送邮件

阻止向 exim 中的某些用户发送邮件

我想阻止某些用户向 中的其他域发送邮件Exim4。我尝试了以下配置,但没有起作用。

exim.conf文件中完成的更改:

在主配置部分,启用acl_smtp_mail控制如下:

acl_smtp_mail = acl_check_mail

然后,在 acl_check_rcpt ACL 配置部分中,创建了一条新规则:

accept   condition = ${lookup{$sender_address}lsearch{/etc/exim/freezelist_sender_addresses}{1}{0}}
         control   = freeze/no_tell

我试过了,但是没有用。请给我一些配置建议。

答案1

您可以使用以下 acl

acl_smtp_rcpt = acl_check_rcpt

acl_check_rcpt:

  deny
     message = The $sender_address is prohibited to send mail to the $domain
     senders = lsearch;/etc/exim/restricted_sender
     domains = lsearch;/etc/exim/restricted_domains

/etc/exim/restricted_sender
[email protected]

/etc/exim/restricted_domains
gmail.com

测试

# swaks -s mail.example.net --to [email protected] --from [email protected]
=== Trying mail.example.net:25...
=== Connected to mail.example.net.
<-  220 mail.example.net, [xxx.xxx.114.28]
 -> EHLO www.example.net
<-  250-mail.example.net Hello www.example.net [xxx.xxx.114.28]
<-  250-SIZE 52428800
<-  250-PIPELINING
<-  250-STARTTLS
<-  250 HELP
 -> MAIL FROM:<[email protected]>
<-  250 OK
 -> RCPT TO:<[email protected]>
<** 550 The [email protected] is prohobited to sent mail to the gmail.com
 -> QUIT
<-  221 mail.example.net closing connection
=== Connection closed with remote host.

答案2

最终解决方案一步一步

  1. 创建文件 restricted_sender。示例:/etc/restricted_sender
  2. 编辑 exim.conf
  3. 在 acl_smtp_rcpt 的开头添加下一条规则:(或者您如何称呼它)

    deny condition = ${lookup{$sender_address}nwildlsearch{/path/to/the/restricted_sender}   {yes}}
      domains = !+local_domains
    

文件/path/to/the/restricted_sender包含每行一封电子邮件:

[email protected]
[email protected]

相关内容