Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text email/mime parser

Tags:

haskell

Does anyone know a good email parser library? Searching Google did not help much.

I have emails dropped locally in maildir format (one mail per file). I need to parse the file extracting body and from parts and save it in a database.

If there is no such thing I could try and write something myself learning on the way. Any advice on how to start would be appreciated. Do I need to learn parsec or is it easy to do without?

like image 412
r.sendecky Avatar asked May 06 '26 09:05

r.sendecky


1 Answers

You could do it using, say, regular expressions. However, learning to write a parser using parsec (or attoparsec) is worth the effort, and this seems like a nice, straightforward example to start with. The next time you need to parse something, you will be glad you did. Parsers you write for parsec will work with attoparsec, and vice versa, as I recall, so it doesn't much matter which you choose. It may be a bit easier to start with parsec, because it automatically reports the location of an error.

I learned Parsec from the documentation. Don't be initimidated by the length of the documentation; you probably won't need to read past page 12 for this task.

like image 155
mhwombat Avatar answered May 09 '26 02:05

mhwombat