CustomFunctions Patch Proposal

davi at davi at
Fri Jun 8 20:36:28 IST 2007

Hello list,

I am developing a tool to configure polices for email with MailScanner. 
This police are store in SQL or XML. I consider that an alteration in the 
official code of the MailScanner is made to support the sending of 
parameter $name of the configuration directive to the custom function. 
Thus function would be possible inside of custom to know which parameter 
is being searched and return the corresponding value. In such a way, is 
not necessary to create a custom function for each directive to use the 
XML police. What you think about ?

The modification (in black)

sub Value {
  my($name, $msg) = @_;
  my($funcname, $result);


  # Make this as fast as possible in simple situations
  return $StaticScalars{$name} if exists $StaticScalars{$name};

  # User custom-written functions are easy to spot too
  $funcname = $CustomFunctions{$name};
  if ($funcname) {
    $funcname = 'MailScanner::CustomConfig::' . $funcname;
    no strict 'refs';
    # Make patch HERE         !   !
    $result = &$funcname($msg,$name);
    use strict 'refs';
    #print STDERR "It was a CF\n" if $name eq 'spamwhitelist';
    return $result;

The CustonFunction with parameter;

sub MailPolice {
          # New here      !       !
        my ($message,$name) = @_;
        MailScanner::Log::InfoLog("MailPolice: DUMPER message " .Dumper($
        MailScanner::Log::InfoLog("MailPolice: DUMPER name " .Dumper($name
        return XmlPoliceGetDirective($name);

so a find <maxmessagesize>100</maxmessagesize> and return proper value 100 
to MailScanner and in MailScanner.conf i made this:

Max Message Size = &MailPolice

What you think about ?

Sr. Julian Field, this patch in are possible?

best regards,

Davi Baldin
JVS do Brasil - IBM BP Premier
davi at
(19) 3254-1266
(19) 9266-6793 ** NOVO **
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the MailScanner mailing list