HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (
-   Server Operation (
-   -   Limit outgoing number of messages in postfix (

pesale86 18th November 2009 18: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 12: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

pesale86 19th November 2009 15:59

Thanks a lot :)

useo6 7th July 2010 23: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 14:43

You can open a Perl shell...

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

install Net::Server::PreFork

afterwards to leave the Perl shell.

useo6 8th July 2010 21:21

works great, thanks :)

useo6 17th July 2010 21: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


smtpd_end_of_data_restrictions = check_policy_service inet:
to which looks like this:


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


[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 05:49.

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