docker-dovecot-mettmail is a Docker image based on Debian implementing a private email gateway with dovecot and mettmail for gathering emails from multiple accounts on a private server (IMAP), but using a public email infrastructure for sending (SMTP).
+-----------+ +-----------+ +--------------+
| ISP | | DOCKER | | LAPTOP |
| | | | +-->|--------------|
| +-------+ | push/delete | +-------+ | push/sync | | MAIL CLIENT +---+
| | IMAPS +----------------->| IMAPS +<------------+ +--------------+ |
| +-------+ | | +-------+ | | +--------------+ |
| +-------+ | | | | | ANDROID | |
| | SMTP |<-------+ | | +-->|--------------| |
| +-------+ | | | | | MAIL CLIENT +---+
+-----------+ | +-----------+ +--------------+ |
+------------------------------------------------------+
Mettmail is currently in active development. This repository uses the latest stable release.
Note: You can use the included docker-compose.yaml
as a starting point. In general you need to do the following to get this setup working:
- Create
mettmail-NAME.yaml
files for the email accounts you want to fetch and put them into theconfig
directory. See theexample-config
directory. - Add a container configuration for each
mettmail.yaml
indocker-compose.yaml
based on the pattern indocker-compose.test.yaml
. Use yourmettmail-NAME.yaml
in volume configuration instead of the example file. - Get or create SSL certificates and put them into the
data/ssl
directory asdovecot.crt
anddovecot.key
. - Start everything using
docker-compose up -d
- Create dovecot users using
./setup.sh adduser USER
and enter a password when prompted. - You can now connect to IMAPS on port 993 using those credentials. Sieve is available on 4190.
Requirements for dovecot container:
/srv/vmail
: volume with user maildirs/etc/dovecot-auth
: volume containing dovecot's passwd-file/etc/ssl/private
: mounted SSL/TLS certificates (dovecot.crt
,dovecot.key
)
Users can be created with ./setup.sh adduser
. The password are stored hashed using SHA512-CRYPT in /etc/dovecot-auth/passwd
. You can also use the helper script dovecot-adduser.sh
inside the dovecot container or edit that file directly, e.g. to override fields like quota.
Requirements for mettmail containers:
/config/mettmail.yaml
: bind-mounted mettmail config file
Base your
7A5F
mettmail.yaml
on those in the example-config
directory.
There is a test setup included for development purposes. You normally don't need to use this. After generating SSL certificates and placing them in data/ssl
(see instructions in docker-compose.test.yaml
) you can start the dovecot server using:
docker-compose up
Then you need to create a user in the dovecot container (username test
is configured in the example mettmail.yaml
but it doesn't yet exist in the dovecot container):
./setup.sh adduser test test
After this initial setup, stop the dovecot server and restart the final test setup:
docker-compose down
docker-compose -f docker-compose.yaml -f docker-compose.test.yaml up
This starts:
- A separate
testcot
container (docker-test-dovecot) with a dovecot listening docker-internally. There are dovecot usersa, b, c, d
, each with passwordpass
. A script is started generating a new mail every minute for each user if that user currently has no new mails. This way we have something for mettmail to fetch every minute. - mettmail containers which connect to
testcot
and receive mails for usersa, b, c
. The mails are delivered to usertest
in the dovecot container.
You can then connect to the dovecot
container using username test
with password test
and see the generated mails which were fetched and delivered by mettmail.
If you run into trouble make sure to bring down the whole setup (docker-compose -f docker-compose.yaml -f docker-compose.test.yaml down
) before restarting it.
Differences to https://github.com/gw0/docker-dovecot-getmail:
- upgraded Debian 10/buster to Debian 11/bullseye
- using mettmail instead of getmail4
- local delivery from mettmail to dovecot using LMTP (instead of LDA)
- runs each mettmail instance in its own docker container (instead of using cron)
- uses dovecot virtual users from passwd-file managed by convenience script
setup.sh
(instead of using PAM with unix users)
- Copyright © 2021-2022 spezifisch [https://github.com/spezifisch/]
- Copyright © 2016-2021 gw0 [http://gw.tnode.com/] <gw.2021@ena.one>
This library is licensed under the GNU Affero General Public License 3.0+ (AGPL-3.0+). Note that it is mandatory to make all modifications and complete source code of this library publicly available to any user.