[Mimedefang] Pseudo-headers for calling SA

Kevin A. McGrail kmcgrail at pccc.com
Wed Apr 5 11:56:39 EDT 2006


----- Original Message ----- 
From: "Philip Prindeville" <philipp_subx at redfish-solutions.com>

> When Mimedefang calls SA, what pseudo-headers does it generate
> in the message and where in the code does it insert them?
>
> I was wondering about the recipients being inserted...
>
> I see where the "Return-Path:" gets generated, but not the recipient
> list...


Well, I add a lot of pseudo headers from MD so that SA can trigger on them
and I believe it adds them to INPUTMSG.

Perhaps these functions will help.

Regards,
KAM

sub change_header_immediately {
  my (%params) = @_;

  &append_header_immediately(%params, change=>1);

  #md_syslog('warning', "Changing $params{'header'} immediately");
}

sub append_header_immediately {
  #IN ORDER TO HAVE A HEADER TEST IN SPAMASSASSIN REACT TO DATA THAT MD
CREATES, WE HAVE TO EDIT THE INPUTMSG FILE PRIOR TO
  #CALLING SA.  USING action_change_header, ETC WILL NOT WORK.  NO CHANGES
TO THIS FILE ARE SAVED SO IF YOU WANT HEADERS
  #ADDED OR APPENDED, USE STANDARD MD CALLS LIKE:
  # action_change_header('Date', $date);
  # &change_header_immediately(header=>"Date: $date");

  my (%params) = @_;

  my ($filehandle, $output, $firstlineonly, $header);

  $filehandle = new IO::File('+< ./INPUTMSG');

  $firstlineonly = 1;

  $params{'change'} ||= 0;

  $header = $params{'header'};
  $header =~ s/^([^:.]*): .*$/$1/;

  if (-s "./INPUTMSG" < 256*1024 && $filehandle) {
    while (<$filehandle>) {
      if ($params{'change'} > 0) {
        if ($_ =~ /^$header:/) {
          $output .= "$params{'header'}\n";
        } else {
          $output .= $_;
        }
      } elsif ($_ =~ /^$/ && $firstlineonly) {
        $output .= "$params{'header'}\n$_";
        $firstlineonly = 0;
      } else {
        $output .= $_;
      }
    }
  }
  seek $filehandle, 0, 0;
  print $filehandle $output;
  close ($filehandle);

  #md_syslog('warning', "Adding $params{'header'} immediately");
}





More information about the MIMEDefang mailing list