[Mimedefang] Block internal messages

Kevin A. McGrail KMcGrail at PCCC.com
Mon Dec 26 22:01:46 EST 2016


On 12/26/2016 9:38 PM, Richard Laager wrote:
> On 12/26/2016 03:35 PM, Marcelo Machado wrote:
>> I am new to Mimedefang and I would like to know if it is possible to
>> block internal messages, (from my domain to my domain) if the number
>> of recipients is greater than 10.
> Anything is possible if you write the custom Perl code required. What
> you have described wouldn't be too terribly hard. No, that's not an
> offer to write it. Look at the @Recipients array. In there, you can
> determine if some recipients are local, and how many. The $Sender
> variable is how you'd determine if the sender is local.
>

filter_sender might be the better way to go. That way you can 
accept/reject/etc.

 From the man page:

    filter_sender is passed four arguments:  $sender is the envelope 
e-mail address of  the  sender  (for  example,
        "<dfs at roaringpenguin.com>").   The  address  may or may not be 
surrounded by angle brackets.  $ip and $name are
        the IP address and host name of the SMTP relay.  Finally, $helo 
is the argument to the SMTP "HELO" command.

Then something to strip to the domain:

#get domain name from an email address
sub get_domain_from_email {
   my ($domain) = @_;

   #REMOVE ANY LEADING/TRAILING <>'s
   $domain =~ s/(^<|>$)//g;
   #REMOVE ANY LEADING/TRAILING SPACE'S
   $domain =~ s/^ *//g;
   $domain =~ s/ *$//g;
   #REMOVE EVERYTHING UP TO THE @ SYMBOL
   $domain =~ s/.*\@//g;

   return $domain;
}

And then a check like if (uc(&get_domain_from_email($sender)) eq 
'MARCELO.ORG') {

    return ('REJECT', "Sorry; Can't send internal email.");
}

Regards,
KAM



More information about the MIMEDefang mailing list