Rate-limiting outgoing e-mail

danf

Active Member
Apr 10, 2006
26
0
151
I would like to help prevent rogue scripts from sending out spam. I found this option in WHM:

The maximum each domain can send out per hour (0 is unlimited)

But, since this is implemented in /etc/exim.pl, it simply drops any messages over the rate limit. This is a bit drastic, especially since the messages are not recoverable, even if they are legitimate.

Is there a way to tell Exim to freeze any messages over the rate limit instead? Then I could have a script that checks for frozen messages, and they could be investigated.

Thanks.
 

ethical

Well-Known Member
Apr 7, 2009
91
5
58
kernow, and exactly how does CSF do anything of the sort of what the OP asked? That is mostly a reporting and logging tool? If you know how why not just say it for the help of everyone?

Further to this discussion, I think the answer lies in the below code in 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 "Domain $domain has exceeded the max emails per hour. Message discarded.\n";
         }
      }
so the part i would assume that needs changing is the last if statement.

can anyone advise as to how to change that IF so that mails are queue and not killed?

Thanks

John
 
@

[email protected]#$*?!

Guest
Anyone ever find a solution to this? I've read up on the online spec for exim but can't seem to make it work. (exim queue keeps crashing).