A mail server in a box.
"A secure, minimal-configuration mail server in a docker container" based on lava/dockermail.
"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 2 separate docker containers:
-
dovecot: The SMTP and IMAP server with DKIM. This container uses postfix as MTA and dovecot as IMAP server. All incoming mail to your own domains is accepted. For outgoing mail, only authenticated (logged in with username and password) clients can send messages via STARTTLS on port 587. In theory it works with all mail clients, but it was only tested with Mail.app.
-
mail-base: This image is just an implementation detail. It is a workaround to allow sharing of configuration files between multiple docker images."
-
Add all domains you want to receive mail for to the file
mail-base/domains
, like this:example.org example.net
-
Add user aliases to the file
mail-base/aliases
, likejohndoe@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.
-
Add user passwords to the file
mail-base/passwords
like thisjohn.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 SHA256-CRYPT
inside.
- Add ssl certificate files to
dovecot/cert
.
- cert.pem: ssl bundle
- key.pem: private key
- Change
MAILHOST
env variable fromdovecot/Dockerfile
.
Change opendkim.keys
file
Change opendkim.sign
file
Change opendkim.trusted
file
Change postfix.main.cf
:
myhostname = example.com
mydestination = mail.example.com
Change dovecot.lda
:
hostname = example.com
-
Build containers:
make
-
Copy DKIM string from output for domain service, something like
mail._domainkey.example.com v=DKIM1; k=rsa; p=<COPY_DKIM_STRING>
-
Run container:
make start
-
Stop container:
Execute docker ps
and get the id of the running container associated with the mail. Then docker stop <pid>
to finish the container.
You can check on /var/log
:
- mail.log: debug information and status.
- mail.err: critical errors.
- Changing any configuration requires rebuilding the image and restarting the container
- No spam filter