elasticsearch | import eml or files from maildir

Install maildir-utils and use

mu view -summary-len=<numberOFlinesOFmailfile> <MAILFILE>

to parse the files and write a json.


cat <YOURSTUFF> | iconv -c -t <YOURCHARSET> | tr -d '\000-\011\013\014\016-\037' > <YOURJSONFILE>

to eliminate bad characters who do not fit into your charset.

Some (windows) mail clients (outlook?) put an CRLF at the end of to, cc, bcc or subject , so do something like an

echo "$to" | sed 's|\r$||'

Elasticsearch will not accept json files encapsulated in square brackets like

[{ "mykey":"myvqlue1"}, ...]

Drop the outer brackets. It should look like

{ "mykey":"myvqlue1"}, ...

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.