exim4 – 为什么限速出站邮件只能与acl_not_smtp一起使用?

为了限制每个收件人发送的电子邮件(所有电子邮件都是由同一个用户发送的),我一直在一个非常简单的环境中进行一些testing:

The Webs ^ | +-------------------+ SMTP? +--------+---------+ | +---------------> | mail.example.com |  | billyw.localhost | | (smarthost) | | (exim4) | | | +-------------------+ +------------------+ 

billyw.localhost是一个Debian机器。 使用dpkg-reconfigure exim4-config ,我将其设置为使用mail.example.com作为智能主机。

目前,我通过向acl_not_smtp添加ACL来限制速率:

 acl_not_smtp = acl_check_not_smtp acl_check_not_smtp: # Rate limit based on the recipient address discard ratelimit = 7 / 1m / per_mail / $recipients log_message = Rate limit exceeded for $recipients: $sender_rate/$sender_rate_period (max $sender_rate_limit) accept 

我正在使用billyw.localhost上的以下命令来testing它:

 for i in {1..10}; do mail -s testing [email protected] <<< '' mail -s testing [email protected] <<< '' done 

这种configuration似乎按预期工作; 它允许通过7个电子邮件到每个收件人,并放弃最后3每个收件人。

但是,如果我尝试在SMTP相关ACL中使用相同的configuration,例如:

  • acl_smtp_connect
  • acl_smtp_rcpt
  • acl_smtp_mail

那么ACL的速率限制条目就不会被挂钩,所有的10条消息都会被发送出去。

为什么当它被放在一个smtp相关的ACL中时不会应用速率限制?

acl_not_smtp相当于SMTPstream量的acl_data 。 在该ACL中尝试限速。 SMTP连接为您提供了更多可以放置消息的ACL选项。 (注意: discard是一个accept的黑洞变种,所以你不会看到拒绝信息。) discard是相当激烈的,我会使用deferdeny SMTPstream量。

速率限制在Exim规范的 第42章第38节中介绍 。 您可以使用修改后的configuration进行testing,以便您可以在执行testing时比您一旦实施时更难评分。 在实施之前,请等待testing限制的时间。

尝试将以下内容添加到您的acl_smtp_rcpt

 defer ratelimit = 7 / 1m / $recipients message = Rate limit exceeded for $recipients: \ $sender_rate/$sender_rate_period (max $sender_rate_limit) 

/usr/bin/mail运行本地sendmail程序来传递邮件,而不是通过networking堆栈连接。 在你的情况下,exim4被用作sendmail的直接replace。 邮件将被视为非SMTP传递。 速率限制将需要使用非smtp ACL完成。