HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   Limit outgoing number of messages in postfix (http://www.howtoforge.com/forums/showthread.php?t=41131)

pesale86 18th November 2009 17:52

Limit outgoing number of messages in postfix
 
Is there some good way to limit outbound mail in postfix? Exactly, I want to limit number of send messages by domain per some time interval.

Imaginary example:

I have email accounts in 3 different domains: tld1, tld2 and tld3. It is not relevant how many accounts in what domain.
All accounts in tld1 can send at most 20 messages per hour.
All accounts in tld2 can send at most 10 messages per hour.
All accounts in tld3 can send at most 25 messages per hour.

Does that can be done? And how?

topdog 19th November 2009 11:13

Postfix does not have built in support for rate limiting, you will have to use a policy daemon for that. a good one is policyd http://www.policyd.org/tiki-index.ph...ModuleFeatures

pesale86 19th November 2009 14:59

Thanks a lot :)

useo6 7th July 2010 22:32

I followed the instructions of the install-file but I can't get it to work. I always get the following error when I try to start the daemon:

Base class package "Net::Server::PreFork" is empty.
(Perhaps you need to 'use' the module which defines that package first.)
at /usr/local/sbin/cbpolicyd line 30
BEGIN failed--compilation aborted at /usr/local/sbin/cbpolicyd line 30.

When I try to install "perl-Net-Server.noarch" by using "yum install perl-Net-Server.noarch", yum says that there is nothing to do.

OS: CentOS 5.5 64Bit

falko 8th July 2010 13:43

You can open a Perl shell...
Code:

perl -MCPAN -e shell
... and install the module as follows:
Code:

install Net::Server::PreFork
Type
Code:

q
afterwards to leave the Perl shell.

useo6 8th July 2010 20:21

works great, thanks :)

useo6 17th July 2010 20:54

Policyd is running, but it seems doesn't work correctly. I created a quota by using the web administration of Policyd with a limit of 1 message/hour (for testing purposes) but I can send and receive as many e-mails as I want. The logfile is also empty (the start sequence is the only entry). It seems that postfix completely ignores policyd.
I also added

Quote:

smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10031
to main.cf which looks like this:

Quote:

[...]
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10031
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_unlisted_recipient, check_policy_service inet:127.0.0.1:10031
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
[...]
Content of policyd logfile:

Quote:

[2010/07/17-20:45:45 - 5972] [CORE] NOTICE: 2010/07/17-20:45:45 Server closing!
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: Process Backgrounded
[2010/07/17-20:45:45 - 6010] [CBPOLICYD] NOTICE: Policyd v2 / Cluebringer - v2.0.8
[2010/07/17-20:45:45 - 6010] [CBPOLICYD] NOTICE: Initializing system modules.
[2010/07/17-20:45:45 - 6010] [CBPOLICYD] NOTICE: System modules initialized.
[2010/07/17-20:45:45 - 6010] [CBPOLICYD] NOTICE: Module load started...
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => AccessControl: enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => CheckHelo: enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => CheckSPF: enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => Greylisting: enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => Quotas: enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => Protocol(Postfix): enabled
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: => Protocol(Bizanga): enabled
[2010/07/17-20:45:45 - 6010] [CBPOLICYD] NOTICE: Module load done.
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: 2010/07/17-20:45:45 cbp (type Net::Server::PreFork) starting! pid(6010)
[2010/07/17-20:45:45 - 6010] [CORE] NOTICE: Binding to TCP port 10031 on host *
[2010/07/17-20:45:45 - 6010] [CORE] WARNING: Group Not Defined. Defaulting to EGID '0 10 6 4 3 2 1 0'
[2010/07/17-20:45:45 - 6010] [CORE] WARNING: User Not Defined. Defaulting to EUID '0'
Looking forward to hearing from anyone :)

Edit:\\ It's working - I forgot to activate the quota-limit and I replaced the old version (2.0.8) with the actual version. When I send an email by using thunderbird or outlook it is working correctly. But, when I try sending with the mail()-function of php, I can send as much as I want. Is there any way to limit this function using policyd?


All times are GMT +2. The time now is 06:07.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.