[Mimedefang] disclamer only for out going mails.

Gary Funck gary at intrepid.com
Sat Dec 17 21:08:27 EST 2005


> From: Jan Pieter Cornet
> Sent: Saturday, December 17, 2005 7:12 AM
> To: mimedefang at lists.roaringpenguin.com
> 
> In this case, through $RelayAddr.

OK, thanks.  Here is the ammended method:

In filter_end() obtain the Sender's IP address from the
$RelayAddr global variable, and check it against the IP addresses
of your local machines, using the technique mentioned
earlier.  If it is determined to be outgoing, then add
the boilerplate.

4. Restart MimeDefang and test.  It would be best to
test this on a test server.

And here, is the candidate code.

First, add this subroutine somewhere above filter_end.

sub is_ip_local ($) {
  use Socket;
  my $ip =  shift @_;
  # List networks that are to be classified as local ip's
  my %local_subnets = (
  '127.0.0.0',            '255.0.0.0',       # loopback
  '192.168.0.0',          '255.255.0.0',     # internal net
  '199.199.199.0',        '255.255.255.0'    # Your Class C address here
  );
  my $addr = inet_aton $ip;
  while (my ($network_string, $mask_string) = each %local_subnets) {
          my $network = inet_aton $network_string;
          my $mask = inet_aton $mask_string;
          if (($addr & $mask) eq $network) {
                  return 1;
          }
  }
  return 0;
}

Modify or delete the line above for your Class C address and mask,
as required.  Add other IP ranges and masks as required.

Then towards the end of filter_end add the following:

     if (is_local_ip ($RelayAddr)) {
       append_text_boilerplate($entity,
                             "text disclaimer", 0);
       apend_html_boilerplate($entity,
                             "HTML disclaimer", 0);
       action_rebuild();
    }

The caveats that Joseph Brennan pointed out apply.  This approach
won't necessarily catch employees who access the mail server from
a remote network, and it will add disclaimers to mail sent from
the internal network by visitors and contractors.  It will also
add the disclaimer to mail sent between employees within the
network, and it will re-add the disclaimier even it is already
present in the e-mail body.  Basically, a lot more work is needed
to cover those additional cases.




More information about the MIMEDefang mailing list