The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Limit the maximum number of each domain can send out per hour

Discussion in 'General Discussion' started by seeyes, Jul 13, 2004.

  1. seeyes

    seeyes Well-Known Member

    Joined:
    Sep 12, 2003
    Messages:
    50
    Likes Received:
    0
    Trophy Points:
    6
    Hello,
    I have see the option "The maximum each domain can send out per hour " in "Tweak Settings".
    These feature permit to limit the number of email per hour, but is possible change the limit per day or per week?
    This is my problem... I have some user with 1000-1500 user in mailing list. If I limit on 1500 per hour they cannot send more then 1500 email per hour but can send 1500 per all hour.

    Can I limit to (for example) 10000 email per day?

    Antonello
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    You can't do that through WHM. It may be possible but would mean trawling through exim.conf/exim.pl etc to find where it's done and then modify the code.
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    Found it in /etc/exim.pl
    Code:
    #logsmtpbw here
       my $now = time();
       $domain =~ s/[^\w\.\-]//g;
    #we just can't trust user input
       my $message_size = Exim::expand_string('$message_size');
    
       if ($domain ne "") {
          my $maxmails = 0;
    
          open(CF,"/var/cpanel/cpanel.config");
          while(<CF>) {
             next if (/^#/);
             s/\n//g;
             my($var,$value) = split(/=/, $_);
             if ($var eq "maxemailsperhour") {
                $maxmails = int($value);
             }
          }
          close(CF);
    
          open(CPM,"/var/cpanel/maxemails");
          while(<CPM>) {
             s/\n//g;
             my($mdomain,$mmax) = split(/=/);
             if ($mdomain eq $domain) {
                $maxmails = int($mmax);
             }
          }
          close(CPM);
    
          if ($maxmails > 0) {
             my $nummailsinhour = readbacktodate("/usr/local/apache/domlogs/$domain-smtpbytes_log");
             if ($nummailsinhour > $maxmails) {
                die "You have exceeded the max emails per hour, your message has been discarded.\n";
             }
          }
    
    
          open(DLOG,">>/usr/local/apache/domlogs/$domain-smtpbytes_log");
          print DLOG "$now $message_size .\n";
          close(DLOG);
          chmod(0640,"/usr/local/apache/domlogs/$domain-smtpbytes_log");
       }
    #end logsmtpbw
    
    It should be fairly straightforward to modify that to your own requirements. You will have to be careful of /scripts/upcp replacing exim.pl when upgrading.
     
  4. nazmy

    nazmy Member

    Joined:
    Oct 31, 2004
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    Changing this would require changingthe sub routine

    Code:
    sub readbacktodate {
       my($filename) = @_;
       my($buf);
       my($filepos) = 0;
       my $now = time();
       my $onehourago = ($now - (60*60));  ----> 60*60*24
    
    i think this would make it run on per day basis

    hope my reply aint too late
     
Loading...

Share This Page