On Mon, 2018-01-22 at 10:05 -0500, Rupert Gallagher wrote: > This is my current solution for a problem that has been discussed > many times in this list. > I wrote it last year, and it serves me well. Feel free to use it, if > you find it useful. > > This part goes into your local.cf: > > header __F_DM1 eval:from_domains_mismatch() > header __F_DM2 From:addr =~ > /\@(pec|legalmail|telecompost)(\.[^\.]+)?\.it/ > meta F_DM ( __F_DM1 && ! __F_DM2 ) > describe F_DM From:name domain mismatches From:addr domain > priority F_DM -1 > score F_DM 5.0 > > This part goes into the general HeaderEval.pm: > > $self->register_eval_rule("from_domains_mismatch"); > [...] > sub from_domains_mismatch { > my ($self, $pms) = @_; > my $temp; > $temp = $pms->get('From:addr'); > $temp =~ /@(.+)/; my $fromAddrDomain; $fromAddrDomain = "$1"; > $temp = $pms->get('From:name'); > $temp =~ /@([^\@\"\s]+)/; my $fromNameDomain; $fromNameDomain = > "$1"; > dbg("from_domains_mismatch: fromNameDomain=$fromNameDomain, > fromAddrDomain=$fromAddrDomain"); > if ( $fromNameDomain eq "" ) { > return 0; # all well > } else { > if( $fromNameDomain eq $fromAddrDomain ) { > return 0; # all well, they match > } else { > return 1; # mismatch, possibly spam > } > } > } > > R.G. > Just for the heck of it I added the above to my SpamAssassin setup at home. However my syslog shows:
rules: failed to run __F_DM1 test, skipping: (Can't locate object method "from_domains_mismatch" via package "Mail: [...]:SpamAssassin::PerMsgStatus" at (eval 1816) line 19.) I did restart SA after adding this. SA version 3.4.1 -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 15:53:56 up 7:41, 1 user, load average: 0.42, 0.71, 0.69 Description: Ubuntu 16.04.3 LTS, kernel 4.13.0-32-generic
signature.asc
Description: This is a digitally signed message part