Adding Signature based on header?

Ken A ka at
Tue Apr 3 17:28:49 IST 2007

Steve Freegard wrote:
> Hi Dhawal/Paul,
> Dhawal Doshy wrote:
>> Paul Hutchings wrote:
>>> I have MailScanner on a Postfix box.
>>> I run one instance on Postfix and 2 Postfix listeners, normal SMTP, and
>>> a separate Authenticated SMTP listener.
>>> I have a Signature rule to only sign email from my internal mail servers
>>> IP address. How would I apply this signature to email sent via the 
>>> Authenticated
>>> SMTP listener?
>>> AIUI Postfix adds some sort of "Authenticated User" header, can I have a
>>> From: rule based on that?
>> MailScanner doesn't support header based rules, however you can write 
>> a custom function to do this..  <quoting Ken A>The headers are 
>> available as @{$message->{headers}} in the Message Object, so you can 
>> use a Custom Function to get the result of a header check and a yes/no 
>> result for a rule.</quoting Ken A>
>> Has anyone on the list written a header based custom function that can 
>> be trivially modified for such a purpose?
> No - but if one of you can mail me some examples - I have some code in 
> MailScanner that does something similar that I should be able to modify 
> and put on the Wiki as this would seem to be pretty useful in a lot of 
> cases.

Here's a trivial example. We use this to avoid using the SA cache on 
messages that for some reason or another we want to score differently 
for different users, so caching the score would break our ability to do 

# don't use SA Cache if a certain header is found.
sub DontCache {
   my($message) = @_;
   return 1 unless $message; # Default if no message passed in
   @fullHeaders = @{$message->{headers}};
         # if mesg was released from a quarantine somewhere else
	if($_ =~ /^X-disposition: released from quarantine at XYZ/){
                 $id = $message->{id};
                 # MailScanner::Log::InfoLog("Not using SA Cache: $id");
                 $dontCache = 1;
	# elsif{ other conditions } { $dontCache = 1; }
   if($dontCache) { return 0; }
   return 1;

Ken Anderson

> Cheers,
> Steve.

More information about the MailScanner mailing list