header __AR_SUBJECT_XXX Subject =~ /XXX/
header __AR_TO_DOMAIN_COM ToCc:addr =~ /\@domain\.com$/i
meta AR_SUBJ_XXX_TO_DOMAIN_COM __AR_SUBJECT_XXX && __AR_TO_DOMAIN_COM
score AR_SUBJ_XXX_TO_DOMAIN_COM 5.0
You'll have to create a perl regular expression matching that subject. If it's literally "XXX" then what I have above will work. If you just want a literal string match and don't want to deal with regular expressions, surround that literal string with \Q
and \E
, like /\QXXX\E/
(or, for case-insensitive, /\QXXX\E/i
). You'll still want to escape your slashes though.
This creates two predicate rules, one to match the subject and one to match either To
or Cc
(using a special pseudo-header designed for that purpose) on its address (using a special modifier to restrict the field to just the address) that matches the given domain. Don't forget to escape your at signs (@
as \@
) and dots (.
as \.
). The $
anchors against the end of the address so you don't match joe@domain.com.br
The predicate rules are combined by the meta
rule that requires both to fire, and when that happens, it will add 5.0 points to the message's spam score (by default, SpamAssassin uses a spam threshold of 5).
This is a broad rule and it seems a bit risky to me, but it literally implements your request. You're definitely better off ensuring that you have DNSBLs and Bayes enabled and functioning properly before you start tinkering with custom rules, as those are the two primary workhorses of SpamAssassin.
Learn more about configuring: