Awesome
<p align="center"> <img src="https://github.com/erebe/hmailfilter/raw/master/log_hmailfilter.png" alt="hmailfilter logo"/> </p>Description
Managing rules with procmail is too cumbersome for me (especially if genericity is required).
So instead, this program will parse email's headers, use the associated rules, and print the destination folder for procmail to use it.
You can see rule and filter examples in app/classifier.hs.
Filter examples
tabulaRasa :: Match Any
tabulaRasa = for $ anyOf ["tabula.rasa@erebe.eu", "editeur.algo@erebe.eu"]
haskellCafe :: Match Any
haskellCafe = mailingList $ anyOf ["haskell-cafe"]
-- Match if ANY of those 3 matches is a hit !
blacklist :: Match Any
blacklist = from (anyOf [".Meds="])
<> for (anyOf ["mediapart@"])
<> subject (anyOf ["pussy", "naked", "fuck"])
-- Match if ALL of those 2 matches is a hit !
fromGod :: Match All
fromGod = from (anyOf ["God"])
<> subject (anyOf ["It's God talking"])
Rule examples
let rules = [ --If all Filters Match then move email to this Dir
, [pourMoi] ->> const "./"
, [devNull] ->> const "/dev/null"
, [tabulaRasa] ->> const ".Compte.TabulaRasa/"
, [pourDomaine] ->> \hs -> ".Compte." <> virtualUser hs <> "/"
]
and procmailrc example in procmailrc file
DEST=`hmailfilter`
:0:
* .
$DEST
What to expect
- Can parse a 62M header only email, without an flinch
- Parse header value that is encoded (Ex: =?UTF-8?B?ABB?= or =?iso-8859-1?Q?=A1Hola,_se=F1or!?=)
How to run ?
To install (only once):
- stack init
- stack install
Now to run:
- Edit your procmailrc and use procmail to run the mail filter
Todo
- Add some reader Monad instead of Hashmap -> Parser HashMap