I need to convert about 500k emails into searchable PDFs. By 'searchable' I mean that macOS will be able to scan them for specific words rather than simply treating them as an image. My searches, thus far, for a tool to do this have ended in proprietary database apps and over-priced sketchball x-to-pdf converters which basically perform the built-in macOS functionality of Print To PDF. Is there a single tool or two complementary tools that could be used together in Terminal to just batch convert all the emails to searchable PDFs?
-
are those all Windows emails– RuskesCommented Dec 29, 2018 at 17:41
-
No, they are not. Some of them are very old Outlook for Mac and Thunderbird files. The majority are Mac Mail files spanning from about 1995 to today.– KerlixCommented Dec 29, 2018 at 19:34
-
just asking, since Thunderbird lets you export as PDF, so does Outlook, so does mac Mail.– RuskesCommented Dec 29, 2018 at 19:42
-
1Mac Mail lets you export either one message at a time, individually, which is not feasible for this quantity of documents, or by merging a folder of emails into one pdf, which is also not desired. The add-on that allowed Thunderbird to batch export individual emails as pdfs has broken, according to user reviews. I haven't used Outlook in years, but would prefer to not convert all the messages an additional time to be readable by Outlook. Also, Date Created Metadata is important to conserve for this scenario.– KerlixCommented Dec 29, 2018 at 21:16
-
I just tried in Mac Mail and selected 50 email and exported them all at once as individual pdf's– RuskesCommented Dec 29, 2018 at 21:21
2 Answers
I had to do this with ~180 emails, and I used a command tool I found on GitHub that converts .eml to .pdf via .html: https://github.com/nickrussler/eml-to-pdf-converter
It takes a little while to convert each .eml file - 22 minutes for 186 emails with lots of images - so it's probably not helpful for a 500k email task. (Maybe if you're reeeally not in a rush and not afraid of multiprocessing!) If it is helpful for you or anyone else, though, here's how I got it to work in the bash command line:
git clone
the repoInstall the
wkhtmltopdf
tool from binary (installing withpip
is insufficient) from here: https://wkhtmltopdf.org/downloads.htmlFrom within the cloned repo, generate the email converter .jar file:
./gradlew shadowJar
Run for loop to convert every file in the .mbox (or a directory of .eml):
for file in /path/to/mailbox.mbox/*;
do
java -jar ./build/libs/emailconverter-2.0.1-all.jar "$file";
done
-
Very useful, thanks! On macOS, a simple
brew install wkhtmltopdf
worked perfectly– mountrixCommented Feb 6, 2023 at 9:15
I recently came across How to open eml files? on AskUbuntu.
It suggests using munpack, which is part of mpack. It can convert an eml
to html
or plain txt
. There are several tools to convert html
to a pdf
. WeasyPrint is one of them. You can install it via pip
.
mpack is also available in Homebrew. Assuming you have Homebrew installed, it's easily installed via:
brew install mpack
Then run
munpack -t <my.eml>
-
Nice find. Might be worth adding at least one way on how to get from HTML/TXT to PDF from the commandline.– nohillside ♦Commented Feb 25, 2020 at 20:07
-
Fair point. I added a tool. It will all require a little bit of scripting. But with these building blocks it should be doable.– VolskCommented Feb 25, 2020 at 20:14