https://github.com/erebe/hmailfilter
Parse and Filter emails - Procmail enchancement
https://github.com/erebe/hmailfilter
Last synced: 10 months ago
JSON representation
Parse and Filter emails - Procmail enchancement
- Host: GitHub
- URL: https://github.com/erebe/hmailfilter
- Owner: erebe
- License: bsd-3-clause
- Created: 2015-04-21T12:04:54.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-08-28T13:53:26.000Z (almost 2 years ago)
- Last Synced: 2025-08-30T23:59:41.934Z (10 months ago)
- Language: Haskell
- Homepage:
- Size: 129 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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
```haskell
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
```haskell
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
```bash
DEST=`hmailfilter`
:0:
* .
$DEST
```
## What to expect
1. Can parse a 62M header only email, without an flinch
2. 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):
1. stack init
2. stack install
##### Now to run:
1. Edit your procmailrc and use procmail to run the mail filter
## Todo
1. Add some reader Monad instead of Hashmap -> Parser HashMap