So i have been trying to make a mail servddder which is functioning fine now what i want now is i want to limit the amount of mail a mail user can send I have tried and failed with policyd I also posted a question for a topic but didnt got any response thought that If any of you guys have the solution to d so
So, basically what i want to achieve is I want to limit 2 email every 5 minutes per user hope That make it clear
So any suggestion about how can i do with That
link of my previous policyd question
Try
postfwd
.A default smtpd on port 25 in my servers always has very tight restrictions:
mynetworks
=127.0.0.1, it doesn't permit any authentication and relaying and so on. It's just for receiving mail from other servers. So such mail server requires anybody to connect to submission port (587) and authenticate to be able to send mail outside.This submission smtpd process at port 587 has a postfwd plugged in as a policy service in the
smtpd_sender_restrictions
. This is configured in/etc/postfix/master.cf
, like this:A policy service at localhost:10040 is the postfwd. Its startup is defined in Debian by
/etc/default/postfwd
, where it has the following (ones which are important for connection with Postfix):This is used by systemd to build a commandline for postfwd executable (it's a Perl script actually). It sets further configuration file to
/etc/postfix/postfwd.cf
, where you define actual rules. Those rules can be arbitrary complex, but for your question it will be very simple, just a single line:rate
is a rate-limiting feature of postfwd, and here it's set to permit 2 messages in 300 seconds, otherwise it'll reject with the specified message.$$sender
is substitied with actual envelope sender of this mail. Please note, it counts each recipient as independend mail; if you try to send a mail with two recipients, it'll count as two mail; if you try to have three recipients, this service will block such message. You see, 2 messages in 5 minutes is very tight restriction.For the compete description of the features of postfwd and syntax of this file please refer to the official postfwd documentation.