[Mimedefang] graphdefang and mailing list activity

Matthew.van.Eerde at hbinc.com Matthew.van.Eerde at hbinc.com
Fri Aug 20 12:17:54 EDT 2004


Rich West wrote:
> I've since built a small snippet to be added to the end of
> filter_sender:
> if (&is_list($sender) && ($hostip == "127.0.0.1")){

Switch the conditions and you'll save a lot of calls to is_list:
if (($hostip == "127.0.0.1") && &is_list($sender)){

> Where is_list is as below (with the %lists being a hash of all lists
> on 
> the system).
> 
> sub is_list
> {
>    my($listname) = shift;
>    ##
>    ## The email address, as it comes in, is surrounded by
>    ## brackets.  We have to massage it a little in order to do
>    ## proper matching.  eg: '<test at testdomain.com>' needs to be
>    'test'. ##
>    $listname = (split("\@", $listname))[0];
>    $listname = (split("\<", $listname))[1];
>    return ($lists{lc($listname)});
> }

Use the power of regexps to save code
sub is_list
{
   my($from) = shift;
   ##
   ## The email address, as it comes in, is surrounded by
   ## brackets.  We have to massage it a little in order to do
   ## proper matching.  eg: '<test at testdomain.com>' needs to be 'test'.
   ##
   return 0 unless $from =~ /^<?(.+?)\@.*>?/;
   my $alias = $1;
   return ($lists{lc($alias)});
}


> However, if I remember correctly, the "from" addresses when dealing
> with mailing lists are not easily matched upon...   I think that is
> where my logic in this scenario starts to fade..
> 
> Thoughts/ideas?

Hmmm... if you can defer your decision to reject until filter_end, you might try running your check against the List-Id: or Sender: header rather than the From:.

Matthew.van.Eerde at hbinc.com                      805.964.4554 x902
Hispanic Business Inc./HireDiversity.com         Software Engineer
perl -e"map{y/a-z/l-za-k/;print}shift" "Jjhi pcdiwtg Ptga wprztg,"



More information about the MIMEDefang mailing list