Incoming message have multiple adresses in the envelope-to
and to
headers. I want to discard all the original recipients and deliver that message to the special single address if some condition matches in ACL. How that can be done?
1 Answer
It sounds like what you want is to classify any email sent to your host directly from an IP in a dynamic range as spam, and feed those messages to SpamAssassin so it can learn the characteristics of those spam messages in case they come from "legitimate" servers.
If that is the case what you want to do can be accomplished without doing regex matches on the email's headers to isolate senders (computationally expensive!), and without rewriting emails (also computationally expensive, adding an extra step), by leveraging DNS blacklists.
- Check your mail against an appropriate DNS block list
(The Spamhaus PBL will have a list of "dyn-ip networks", and it is almost certainly more accurate & less time-consuming than a list you maintain by hand. Alternatively you could use the Zen list and catch lots of other stuff too) - If the mail is a hit on the blacklist:
- Feed it to SpamAssassin (
pipe sa-learn
) - Discard the message (
fail
orfinish
it as you desire)
- Feed it to SpamAssassin (
I'm not an Exim expert, but from examining the documentation this whole chain can be assembled using exim filter files and a dnsdb
lookup (in place of the built-in blacklist support).
If you want to then add your regex matching as additional conditions you can certainly do that as well, but no recipient rewriting appears to be necessary.
-
If someone happens to assemble such a filter please post it as an answer - I don't have an exim box around to test with, but I'll happily upvote a working solution that's more than just my algorithmic outline– voretaq7Mar 14, 2012 at 19:40
-
can I post my currenf config as answer to my own question? I'm not familiar enough with serverfault and don't know local rules in depth.– KondybasMar 15, 2012 at 23:59
[email protected]