aboutsummaryrefslogtreecommitdiff
path: root/_posts/2018-06-01-mailu.md
blob: a3a0efd62b789c1b09d88850dda42174eb9e8c4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
layout: post
title:  "Mailu"
date:   2018-06-01 20:17:00 +0100
categories: jekyll update
---

I'm a big user of Google's software & services. Sometimes though, I wonder if I am too dependent on their services. The saying I have heard is that if you aren't paying for the product, then you are the product. I can use Google's services on their terms, which may include picking through my data for whatever reason.

Having recently acquired a [Raspberry Pi][rpi], I decided to see what I could move my data away from Google's cloud and back into my own home. I made the following list of services that I regularly use:

* Email
* Instant messaging
* Social media
* Photo storage
* Document storage

This blog post is about email. Email is great. Email has been around since the very early internet days, and there are numerous excellent free & open-source bits of software that do email. At first glance, it may seem trivial to download all the relevant software, get it configured and hey presto, you have an email server. This isn't quite how this project turned out.

Dovecot for IMAP. Postfix for SMTP. Get this working basically first, then add: Spamassassin for spam filtering, then clamav for anti-virus. Then maybe roundcube for webmail...

I quickly found myself mired in configuration choices. Did I want real user accounts on my pi, or virtual user accounts in a database? How do I route the mail through spamassassin? Do I allow incoming mail from the local network without authentication? 

There is plenty of [documentation][dovecot-basic] and [guides][ars-technica-guide] about how to (and why) set up your own email server. The arstechnica guide I particularly like because it sets the scene so well: 

>Why do battle with arcane dragons to roll your own e-mail solution?

Eventually I actually gave up trying to configure by myself all the services required to do email properly. It would have taken way more time, research, and testing than I was willing to put in. So I started looking for alternative routes. 

Around the same time, I was revisiting the [Go][golang] programming language. There is now an excellent minimal-configuration web server called [Caddy][caddy], written in go, with a simple configuration file and good stuff like HTTPS & HTTP/2 included by default. I embarked on a mission to write [my own mail server 'gomail'][gomail] with the same principles. This kind of worked, except it turns out to be a monumental effort to correctly implement the IMAP and SMTP protocols. A kind soul [emersion][emersion] has actually done most of the hard protocol work, creating nice go wrappers for SMTP and IMAP. Even with all this background work completed, it's still a monumemtal task. Emersion had already tried with [maddy][maddy], but as of writing this blog it's still very much incomplete. The idea has even been discussed on the [Caddy forums][caddy-forum-non-http], but no real progress made.

There are a couple of alternative ways to get a good mail server setup: [iRedMail][iredmail] offers what is essentially a configuration script to get a new Debian / Ubuntu install to become a working mail server. This approach works fine, as long as you are starting with a fresh Debian install.

This approach actually leads really neatly onto the last solution I tried, and the one I actually have working: [Mailu][mailu]. This project provides all the same open-source email components (postfix, dovecot), but pre-configured and packaged as [Docker][docker] images. This has a couple of advantages over iRedMail: 
* You don't need a fresh Debian install. You only need a working Docker installation.
* You can configure & run other services on the same machine without interference.
* It's more easily portable: copy over the single /var/lib/mailu directory to another machine, and spin up all the servers again with `docker-compose up` and it's all back up & working again.

The project didn't work out of the box with Raspberry Pi - not all the base images are ARM compatible. This was a pretty easy thing to fix though, and I now maintain a permanent fork of mailu for Raspberry Pi over [here][mailu-rpi]

[rpi]:https://www.raspberrypi.org/
[dovecot-basic]:https://wiki.dovecot.org/BasicConfiguration
[ars-technica-guide]:https://arstechnica.com/information-technology/2014/02/how-to-run-your-own-e-mail-server-with-your-own-domain-part-1/
[golang]:https://golang.org/
[caddy]:https://caddyserver.com/
[gomail]:https://github.com/MFAshby/gomail
[emersion]:https://github.com/emersion
[maddy]:https://github.com/emersion/maddy
[caddy-forum-non-http]:https://caddy.community/t/server-types-other-than-http/65/7
[iredmail]:https://www.iredmail.org/
[mailu]:https://github.com/Mailu/Mailu
[docker]:http://docker.io/
[mailu-rpi]:https://github.com/MFAshby/mailu