Go to file
2023-12-28 11:17:23 +01:00
brew Get homebrew recipe in place for email2pdf. 2020-07-14 11:53:21 +01:00
debian/DEBIAN Switch to using inbuilt urllib for fetching. 2020-04-19 12:53:23 +01:00
docker/email2pdf Consolidate Dockerfiles. 2014-12-25 19:33:43 +00:00
performance Add initial performance profiling support. 2015-11-02 22:10:15 +00:00
tests Handle badly declared charsets in message body 2021-06-23 10:14:55 +02:00
__init__.py Set up use as a library 2021-01-20 13:40:56 +01:00
.dockerignore Don't copy debs into Docker. 2015-01-02 12:49:30 +00:00
.envrc Switch to explicit python3. 2021-02-06 21:17:22 +00:00
.gitignore Use envrc for local python. 2021-02-06 20:23:34 +00:00
.travis.yml Add build notifications. 2016-02-09 22:50:15 +00:00
email2pdf Handled wayland warning 2021-12-03 16:03:44 +01:00
email2pdf.py Replaced bad module with symlink 2021-03-25 10:08:15 +01:00
getmailrc.sample Add --mostly-hide-warnings flag. 2015-08-19 00:26:01 +02:00
HACKING.md Fix style issue. 2020-09-05 10:56:36 +01:00
LICENSE.txt Update copyright date. 2016-01-26 22:14:05 +01:00
Makefile Remove Docker support. 2021-01-23 09:40:42 +00:00
MANIFEST.in Set up use as a library 2021-01-20 13:40:56 +01:00
PKGBUILD_template Add missing dependencies for Arch. 2020-05-25 01:06:07 +01:00
README.md Update README.md 2021-06-20 18:45:54 +01:00
requirements_hacking.txt Simplify pdfminer by upgrading to pdfminer.six. 2020-08-19 15:51:03 +01:00
requirements.txt Pin dependencies 2023-12-28 11:17:23 +01:00
setup.py Set up use as a library 2021-01-20 13:40:56 +01:00


⚠️ DEPRECATED: This repository is deprecated, as I don't use email2pdf any more or have the time to maintain it. For now, it will remain here in case anyone wishes to fork and maintain it.

email2pdf is a Python script to convert emails to PDF from the command-line. It is not interactive (it doesn't run from a browser or have a GUI), but is intended to be run as a mail delivery agent - it won't retrieve emails for you, but it will take them from standard input as an MDA will and 'deliver' them to PDF files. It is well-placed to use together with getmail, perhaps run on a schedule using cron or similar. You can also just use it as a standalone utility to convert a raw email (normally an .eml file) to a PDF. Type email2pdf --help for more information on usage and options available.

For more information on hacking/developing email2pdf, please see HACKING.md. Note that use is subject to the license conditions.

Installing Dependencies

Before you can use email2pdf, you need to install some dependencies. The instructions here are split out by platform:


  • wkhtmltopdf - Install the .deb from http://wkhtmltopdf.org/ rather than using apt-get to minimise the dependencies you need to install (in particular, to avoid needing a package manager).

  • getmail - getmail is optional, but it works well as a companion to email2pdf. Install using apt-get install getmail.

  • Others - there are some other Python library dependencies. Run make builddeb to create a .deb package, then install it with dpkg -i mydeb.deb. This will prompt you regarding any missing dependencies.


  • wkhtmltopdf - Install the package from http://wkhtmltopdf.org/downloads.html.

  • getmail - TODO: This hasn't been tested, so there are no instructions here yet! Note that getmail is optional.

  • Install Homebrew

  • xcode-select --install (for lxml, because of this)

  • brew install python3 (or otherwise make sure you have Python 3 and pip3 available).

  • brew install libmagic

  • pip3 install -r requirements.txt

Configuring getmail

getmail is not strictly a dependency, but when it is combined with email2pdf, it can be used to retrieve new emails from a remote IMAP server and automatically convert them to PDFs locally. The getmailrc.sample file in the repository can be used as a starting point for your own getmailrc to do this. Note that the sample will need editing, of course - see the getmail documentation for more information on that. Also, it is configured by default to delete remote emails from the server once they are converted - be careful with that. You might want to consider setting up your crontab something like this:

  @hourly getmail --verbose | logger

This will ensure that getmail is invoked hourly to fetch email, and log its output to syslog.

If your mailserver is unreliable, you might want to consider wrapping the getmail cron job with cromer.

Configuring procmail

I don't have any direct experience using procmail with email2pdf, so don't have any specific setup steps, although I understand it can be made to work. You should be aware that currently there is an outstanding issue with I/O encodings with procmail that you may need to work around - see issue #76 for more information.

Harvinderpal Ghotra has refactored email2pdf into a library, which may be helpful if you need to embed email2pdf-like functionality in a Python program (although there is no specific effort to keep these two projects in sync).