It’s been a rocky journey for me to find an easy way to archive my email in a private manner. By private, I mean on a server that I control and hosted at home. I’m not that keen on Google trawling through years and years of my email, and I can’t trust that they’ll maintain the integrity of it (I’m my number one customer, instead of one in a few hundred million for Google).
I started with storing everything in PST files (I’m still an avid Outlook user) with a new file each financial year and emails grouped into folders of their type or topic (e.g. Web Hosting for everything pertaining to that, PayPal receipts, etc.). This approach started to concern me that I’d be locked into only using Outlook forever, and became difficult to search on the odd occasion that I needed to.
So then I moved to extracting my email with Emailchemy (a great piece of software) into .eml files. EML files are great, because they’re plaintext files (with attachments as Base64) and I was able to use Windows Explorer to search through them. But it started to suffer the exact same problems as the PST approach, especially if the directory isn’t indexed.
Next I moved back to PSTs, but I merged everything back into a single PST file and just put them in folders by year (2015, 2014, etc). This became the lowest-friction solution, but I got my concerns back of the tie-in to Outlook, plus the risks of the PST getting corrupted (easy to occur if you put it on a network share), and ways to effectively backup the PSTs on a regular basis.
I would always read that the “easiest” way to store old email is in an IMAP server, and the most favoured approach for an IMAP server is a Postfix+Dovecot arrangement. I have to confess I tried, and failed, to get a dovecot server running the way I wanted. I got it up and running (after loads of modifications to config files in Dovecot and Postfix), and was able to add it as an account in Outlook, but I couldn’t add IMAP folders on the client-side, only on the server-side. And it just plain confused me trying to add folders into the Maildir. Email servers really aren’t my specialty.
I dug around more and found YunoHost, a really nice all-in-one package for self-hosting email and other applications. I really had trouble though installing it (perhaps due to running in Hyper-V, I didn’t troubleshoot), and the instance that I did get up and running was kept throwing errors when I tried to install apps, so I decided to keep on looking for other products.
I ran into iRedMail a few times, but their site was a little off-putting to me (the sales stuff is always a bit of a deterrent to me), but I was really running out of options at this point. And there was no way in hell I was going to install Exchange at home, as I simply don’t have enough RAM to spare for it. iRedMail has turned out to be amazingly easy, and exactly what I was looking for in a self-hosted Mail server. Installation effectively involves just running a bash script, and everything is taken care of. Even firewall configuration and enabling the services, which was a truly pleasant surprise. And I get IMAP folder creation straight from the Roundcube GUI.
Installing iRedMail on CentOS 7
So here’s all it took to get iRedMail up and running correctly in my testbed:
This was in a test environment, so it was just simpler to disable SELinux and worry about it later.
1 2 3 4 5 6 7
# ssh to the server # elevate sudo su # disable selinux sed -i 's/enforcing/disabled/g' /etc/selinux/config reboot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# ssh to the server # elevate sudo su # update yum update -y # install prerequisites yum install wget bzip2 -y # download and unpack iRedMail wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.2.tar.bz2 tar -xvf iRedMail-0.9.2.tar.bz2 cd iRedMail-0.9.2 sh iRedMail.sh
It’s as simple as that. bzip2 needs to be installed, otherwise the tarball won’t extract. The bash script will run you through the installation process, prompting you to provide passwords for the administrative accounts. I also picked MariaDB/MySQL as the database, as it’s what I’m most comfortable with at the moment. Post installation involves authenticating to the administration site (https://sitename/iredadmin/) and creating the necessary users.
The iRedMail installation script only works well if you run it on a vanilla, minimal install server. If you’ve already configured other things like the firewall (perhaps by defining the default zone), then the firewall rules in the script will not be applied. It’s much simpler to let the installer run on a blank machine, and then make the modifications you want.
New Archival Strategy
So now with an IMAP server, I can renew my archival processes. Instead of storing everything as PST files, I can just dump the emails into the respective IMAP folders. To backup my email, I run a daily tarball (with encryption) on the server and store it somewhere with redundancy. Should I wish to move the email to a different location in the future, it’s just a matter of moving the email from one IMAP server to another, so I should be future-proof.
Extra: Installing Postfix & Dovecot on CentOS 7
I might as well also share my testing with installing dovecot, in case you’re wondering what I did. I mostly followed this guide, with some tweaks (like adding “<” to the cert path in the dovecot config). It’s also written to just use echo to build the config files, so it’s a little difficult to read but almost entirely scriptable (except for the mysql_secure_installation).