From: Mike Spamassassin [mailto:[EMAIL PROTECTED]
> 
> This is working pretty well so far.
> Thanks for you help with this.
> 
> I would like to enhance it to cater for the situations where I am
> not in the "To" address (e.g. I am in CC: to Bcc: or the "mailing
> list" situation.
> 
> How would I do a test of the form:
> 
> If To: email address contains ernstoff.net then check for To: real
> name contains Mike or Michael or is blank?

That is a bit more complex.  Meta rules may be the best way to go
here.

    header _TO_MYEMAIL To:addr =~ /ernstoff\.net/i
    header _CC_MYEMAIL Cc:addr =~ /ernstoff\.net/i
    
    header _TO_MYNAME To:name =~ /\b(?:Mike|Michael)\b|^$/i
    header _CC_MYNAME Cc:name =~ /\b(?:Mike|Michael)\b|^$/i
    
    meta NOT_MY_NAME (_TO_MYEMAIL && ! _TO_MYNAME) 
         || (_CC_EMAIL && ! _CC_MYNAME)
    describe NOT_MY_NAME My email address, but not my name
    score NOT_MY_NAME 1

(Note that the meta command should be all on one line)

The rule names that start with an underscore are defined as sub-rules
and are not scored separately.

Also, keep in mind that the :addr and :name modifiers only grab the
first address or real name on the line.  If there are multiple
addresses or real names, they are ignored.  You may have better
results just leaving off the :addr and :name modifiers and accepting
that it will miss a few by matching the name inside the email address
([EMAIL PROTECTED], for example).

    header _TO_MYEMAIL To =~ /ernstoff\.net/i
    header _CC_MYEMAIL Cc =~ /ernstoff\.net/i
    
    header _TO_MYNAME To =~ /\b(?:Mike|Michael)\b(?!\@)|^$/i
    header _CC_MYNAME Cc =~ /\b(?:Mike|Michael)\b(?!\@)|^$/i
    
    meta NOT_MY_NAME ( _TO_MYEMAIL && ! _TO_MYNAME ) 
         || ( _CC_EMAIL && ! _CC_MYNAME )
    describe NOT_MY_NAME My email address, but not my name
    score NOT_MY_NAME 1

The extra stuff on the name regex ensures that the name is not
immediately followed by an "@" to try to avoid matching on obvious
email addresses.

It is possible to parse it all out, but as there are quite a few valid
formats, this would be far more trouble than it is worth.

Bowie

Reply via email to