notmuch-to-kindle is small tool to transfer notmuch emails to Kindle in mobi format, using calibre’s utility programs (most importantly ebook-convert).
It currently extracts all mime parts, post-processes some (at this time, only .html and .doc, future versions will support epub as well), and copies all acceptable files (.mobi, .azw, .pdf) to your chosen Kindle search path.
.doc is converted via html through abiword. If it is missing, notmuch-to-kindle will output an error to stderr and proceed, ignoring the attached file.
If an email has both a text/plain and a text/html part, the HTML part will be extracted and exported to .mobi. If it only has a text/plain part, it will be extracted and copied without further conversion.
- Calibre’s command-line tools (ebook-convert, ebook-device).
- Python notmuch bindings.
On invocation the program will look for the ~/.notmuch-to-kindlerc file, which should contain something like this:
[main] tag=read/review max=15 target=prs500:/documents/mail [ebook-convert] input_profile=kindle
These are all the options available. Target specifies the ebook-device target to copy the finished files to, max is how many files to copy (max), and tag is the tag used to mark the emails to export from notmuch.
- Some attachments with unicoded file names won’t be extracted, because of a failure having to do with RFC2231. Email.utils.decode_rfc2231 won’t work, for some reason. I believe this to be a bug in Python. Suggestions welcome.