lava / dockermail

Ready-to-use email server + (optional) web mail + (optional) caldav, carddav and a kitchen sink in a docker container
MIT License
300 stars 60 forks source link

dockermail

A mail server in a box.

A secure, minimal-configuration mail server in a docker container, including webmail.

This repository is tailored to small private servers, where you own some domain(s) and want to receive the mail for and send mail from this domain. It consists of 4 separate docker containers:

Setup

1) Copy the example files into your own configuration:

cp mail-base/aliases.example mail-base/aliases
cp mail-base/domains.example mail-base/domains
cp mail-base/passwords.example mail-base/passwords

2) Add all domains you want to receive mail for to the file mail-base/domains, like this:

example.org
example.net

3) Add user aliases to the file mail-base/aliases, like

johndoe@example.org         john.doe@example.org
john.doe@example.org        john.doe@example.org
admin@forum.example.org     forum-admin@example.org
@example.net            catch-all@example.net

An IMAP mail account is created for each entry on the right hand side. Every mail sent to one of the addresses in the left column will be delivered to the corresponding account in the right column.

4) Add user passwords to the file mail-base/passwords like this

john.doe@example.org:{PLAIN}password123
admin@example.org:{SHA256-CRYPT}$5$ojXGqoxOAygN91er$VQD/8dDyCYOaLl2yLJlRFXgl.NSrB3seZGXBRMdZAr6

To get the hash values, you can either install dovecot locally or use lxc-attach to attach to the running container and run doveadm pw -s <scheme-name> inside.

5) Build containers:

make

You can build single targets, so if you dont want the webmail you can just run make dovecot instead. The Makefile is extremely simple, dont be afraid to look inside.

6) Run container and map ports 25 and 143 from the host to the container. To store your mail outside the container, map /srv/vmail/ to a directory on your host. (This is recommended, otherwise you have to remember to backup your mail when you want to restart the container) This is done automaticaly by

make run-all

Again, you can make run-dovecot or run-rainloop to only start specific containers. Look at the Makefile to see what this does exactly. Note that you have to stop old containers manually before invoking make, as this currently cannot be done automatically.

7) (Optional) If you want to use owncloud, enter the public url at which owncloud can be reached (e.g. owncloud.example.org) into the file owncloud/public_url.

8) Enjoy.

Known issues / Todo / Wishlist

Patches welcome!