Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 18th November 2009, 17:52
pesale86 pesale86 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?
Reply With Quote
Sponsored Links
  #2  
Old 19th November 2009, 11:13
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 152 Times in 149 Posts
Default

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
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
The Following User Says Thank You to topdog For This Useful Post:
useo6 (8th July 2010)
  #3  
Old 19th November 2009, 14:59
pesale86 pesale86 is offline
Junior Member
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot
Reply With Quote
  #4  
Old 7th July 2010, 22:32
useo6 useo6 is offline
Junior Member
 
Join Date: Jul 2010
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #5  
Old 8th July 2010, 13:43
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

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.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
useo6 (9th July 2010)
  #6  
Old 8th July 2010, 20:21
useo6 useo6 is offline
Junior Member
 
Join Date: Jul 2010
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default

works great, thanks
Reply With Quote
  #7  
Old 17th July 2010, 20:54
useo6 useo6 is offline
Junior Member
 
Join Date: Jul 2010
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
 
Default

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?

Last edited by useo6; 18th July 2010 at 18:14.
Reply With Quote
Reply

Bookmarks

Tags
limit, postfix

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Attacks on MTA dclardy Installation/Configuration 4 29th September 2009 16:50
Postfix not responding to telnet CarbonCopy Server Operation 6 8th May 2009 05:39
localhost postfix/master: fatal: bind 127.0.0.1 port 125: Permission denied g18c Installation/Configuration 4 24th March 2009 17:39
Centos 4.4 32bit Hangs, High Server load 3cwired_com Server Operation 11 16th November 2006 15:47
Verify email setup meekish Installation/Configuration 28 27th October 2006 15:36


All times are GMT +2. The time now is 04:14.


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