custom function

Valmiki N. Ramsewak lilvalo at MIKIBOY.COM
Tue Jul 13 17:23:28 IST 2004


On Mon, Jul 12, 2004 at 09:01:25AM +0100, Julian Field wrote:
> At 21:33 11/07/2004, you wrote:
> >        So then I started looking into writing a CustomFunction
> >
> >        /opt/MailScanner/lib/MailScanner/CustomFunctions/MyExample.pm is
> >        the files that came with MailScanner and put my code in there.
> >
> >        This is my code:
> >        sub InternalForward {
> >          my($fromac, $fromdomain, $todomain, $return);
> >          my($message) = @_;
> >          $fromac = lc($message->{from});
> >          $fromdomain = $fromac;
> >          $fromac =~ s/\@.*$//;   # Leave everything before @
> >          $fromdomain =~ s/^.*\@//; # Leave everything after  @
> >          $return = "forward ".$fromac."-spam".$fromdomain;
> >          MailScanner::Log::InfoLog($return);
> >          return $return;
> >        }
> >
> >I copied a bunch of it from some other file I was reading to figure out
> >how to code it. Mailscanner starts up perfectly fine :) but then when I
> >send some spam mail to the address (yes I have some saved spam mail for
> >testing :) , actually a few thousand :) ) it goes to the inbox and not the
> >spam folder.
>
> You need to
> 1) Add a sub InitInternalForward (it doesn't need to do anything, just
> exist).
> 2) Add a sub EndInternalForward
> 3) Set "Spam Actions = &InternalForward" so that your code is called.
>
> If you code is being executed, the output of InfoLog will be your syslog,
> whatever program you use to provide that service (I have never used
> metalog).

sub InternalForward {
  my($fromac, $fromdomain, $final);
  my($message) = @_;
  $fromac = lc(@{$message->{to}});  // <--- that messed up line
  $fromdomain = $fromac;
  $fromac =~ s/\@.*$//;   # Leave everything before @
  $fromdomain =~ s/^.*\@//; # Leave everything after  @

  $final = 'forward ' . $fromac . '-spam@' . $fromdomain;
  MailScanner::Log::InfoLog('$final');
  return $final;
}

Ok, thats my code as it stands now :) that messed up line is what is
giving me hell... its suppose to grab the to email address

$fromac = lc(@{$message->{to}});   -> that jus loses my email
$fromac = lc{$message->{to});    -> that jus send it to some memory
address   :

                      The Postfix program

<"array(0x9b59ab8)-spam"@array(0x9b59ab8)>: bad address syntax:

$fromac = lc{$message->{from});  -> that modifies the from and not the to
address..


please please, i'm not sure what to do.. thank

valmiki

--
Got Speed?

www.mikiboy.com
aim: lilvalo

-------------------------- MailScanner list ----------------------
To leave, send    leave mailscanner    to jiscmail at jiscmail.ac.uk
Before posting, please see the Most Asked Questions at
http://www.mailscanner.biz/maq/     and the archives at
http://www.jiscmail.ac.uk/lists/mailscanner.html



More information about the MailScanner mailing list