Reject instead of deferring for local sendmail
2014-11-26 by Georgi Petrov
Hello,
It works as expected, any mail over the limit is rejected with "Message quota exceeded" message for SMTP clients (like Thunderbird, etc.).
The problem is, if the message is send through PHP mail() function (using the local sendmail program) it is not rejected, but deferred (goes in the queue) (fragment from the mail log, actual addresses are replaced):
We are experimenting with rate limiting the outgoing mails. Basically this prevents hacked email accounts and hacked websites from sending spam. Currently we have the following configuration in the greylist:
# Whitelist root - this is for all system messages, etc.
racl whitelist from root@...
# Outgoing Mail Rate Limit - 50 messages for 30 minutes
ratelimit "outgoing_mail_limit" rcpt 50 / 30m key "%f"
racl greylist from /.*/ ratelimit "outgoing_mail_limit" delay 31m autowhite 0m msg "Message quota exceeded"
racl whitelist default
The problem is, if the message is send through PHP mail() function (using the local sendmail program) it is not rejected, but deferred (goes in the queue) (fragment from the mail log, actual addresses are replaced):
milter-greylist: ratelimit overflow for class outgoing_mail_limit: 19187, limit is 50 recipients / 1800 sec, key = "user@..."
milter-greylist: 4141D1C67C57: addr localhost[127.0.0.1] from user@....com to user@... delayed for 00:19:46 (ACL 73)
postfix/cleanup[25357]: 4141D1C67C57: milter-reject: RCPT from localhost[127.0.0.1]: 4.7.1 Message quota exceeded; from=<user@...in.com> to=<user@otherserver.com>
postfix/cleanup[25357]: warning: 4141D1C67C57: milter configuration error: can't reject recipient in non-smtpd(8) submission
postfix/cleanup[25357]: warning: 4141D1C67C57: deferring delivery of this message
This is basically what happens when a website is hacked and hundreds of email messages are sent through a PHP script. So milter-greylist actually stops them from being sent, but unfortunatelly they fill up the queue. This then creates other problems (I/O load, unable to queue other messages, etc.) so it is like half solution.
Is there a way we can reject or drop instead of deferring any message over the queue even for non smtpd submission (when sent through PHP mail or local sendmail)?
Thanks a lot for your suggestions and help!
milter-greylist: 4141D1C67C57: addr localhost[127.0.0.1] from user@....com to user@... delayed for 00:19:46 (ACL 73)
postfix/cleanup[25357]: 4141D1C67C57: milter-reject: RCPT from localhost[127.0.0.1]: 4.7.1 Message quota exceeded; from=<user@...in.com> to=<user@otherserver.com>
postfix/cleanup[25357]: warning: 4141D1C67C57: milter configuration error: can't reject recipient in non-smtpd(8) submission
postfix/cleanup[25357]: warning: 4141D1C67C57: deferring delivery of this message
This is basically what happens when a website is hacked and hundreds of email messages are sent through a PHP script. So milter-greylist actually stops them from being sent, but unfortunatelly they fill up the queue. This then creates other problems (I/O load, unable to queue other messages, etc.) so it is like half solution.
Is there a way we can reject or drop instead of deferring any message over the queue even for non smtpd submission (when sent through PHP mail or local sendmail)?
Thanks a lot for your suggestions and help!
Georgi