[Mimedefang] Appending a header for an SA test

Kevin A. McGrail kmcgrail at pccc.com
Tue Apr 26 17:19:35 EDT 2005


I've got the following working to modify INPUTMSG prior to calling
SpamAssassin so I can add headers that then trigger SA rules.  Just
wondering if anyone has any input on a "prettier" way to do it.

KAM


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 (I Think)
  my (%params) = @_;

  my ($filehandle, $output);

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

  if (-s "./INPUTMSG" < 256*1024 && $filehandle) {
    while (<$filehandle>) {
      if ($_ =~ /^$/) {
        $output .= "$params{'header'}\n$_";
      } 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