Coder Social home page Coder Social logo

docker-dovecot-getmail's Introduction

docker-dovecot-getmail

docker-dovecot-getmail is a Docker image based on Debian implementing a private email gateway with dovecot and getmail for gathering emails from multiple accounts on a private server (IMAP), but using a public email infrastructure for sending (SMTP).

It is a Docker container realizing a similar architecture to:

+-----------+              +-----------+               +--------------+
| ISP       |              | DOCKER    |               | LAPTOP       |
|           |              |           |           +-->|--------------|
| +-------+ | push/delete  | +-------+ | push/sync |   |  MAIL CLIENT +---+
| | IMAPS +----------------->| IMAPS +<------------+   +--------------+   |
| +-------+ |              | +-------+ |           |   +--------------+   |
| +-------+ |              |           |           |   | ANDROID      |   |
| | SMTP  |<-------+       |           |           +-->|--------------|   |
| +-------+ |      |       |           |               |  MAIL CLIENT +---+
+-----------+      |       +-----------+               +--------------+   |
                   +------------------------------------------------------+

Open source project:

Usage

Requirements:

  • /home: mounted users directories (Maildir in fs layout, sieve, .getmail)
  • /etc/cron.d: mounted crontabs for executing all getmail accounts
  • /etc/ssl/private: mounted SSL/TLS certificates (dovecot.crt, dovecot.key)

Prepare your getmailrc account configurations per user (/srv/mail/home/user/.getmail/[email protected]):

# ~/.getmail/getmailrc-*: getmailrc email configuration

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.email.invalid
username = [email protected]
port = 993
password = password
mailboxes = ("INBOX", "Sent", "Spam")

[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
arguments = ("-e",)

[options]
read_all = false
delete_after = 30
delivered_to = false
received = true
verbose = 1

If you are using Sieve filters and want a Refilter mailbox to trigger their refiltering, create a refilter configuration per user (/srv/mail/home/user/.getmail/getmailrc-refilter):

# ~/.getmail/getmailrc-*: getmailrc refilter configuration

[retriever]
type = SimpleIMAPRetriever
server = localhost
port = 143
username = user
password = password
mailboxes = ("Refilter",)

[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
arguments = ("-e",)

[options]
read_all = false
delete = true
delivered_to = false
received = false
verbose = 1

Prepare crontab file (/srv/mail/cron.d/getmail) for periodically checking for new mail for each user and account:

# /etc/cron.d/getmail: system-wide crontab for getmail
SHELL=/bin/sh

# m h dom mon dow user  command
*/20 *  *   *   * user  ACC="user-refilter" && (date; flock -n ~/.getmail/lock-$ACC getmail --rcfile="getmailrc-$ACC" --idle Refilter) >>"/var/log/getmail/$ACC.log" 2>&1
*/20 *  *   *   * user  ACC="[email protected]" && (date; flock -n ~/.getmail/lock-$ACC getmail --rcfile="getmailrc-$ACC" --idle INBOX) >>"/var/log/getmail/$ACC.log" 2>&1

Do not forget to place your SSL certificates as /srv/mail/ssl/dovecot.crt and /srv/mail/ssl/dovecot.key. SSL is required!

And finally start it with docker:

$ docker run -d -v /srv/mail/home:/home -v /srv/mail/cron.d:/etc/cron.d -v /srv/mail/ssl:/etc/ssl/private:ro -p 143 -p 993 -p 4190 --name mail gw000/dovecot-getmail

Or use docker-compose (check out docker-compose.example.yml).

Users are created automatically with default password (replaceMeNow) on first start. To reset user passwords (of a running container):

$ docker exec -it mail passwd user

Feedback

If you encounter any bugs or have feature requests, please file them in the issue tracker or even develop it yourself and submit a pull request over GitHub.

License

Copyright © 2016-2021 gw0 [http://gw.tnode.com/] <[email protected]>

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.

docker-dovecot-getmail's People

Contributors

gw0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-dovecot-getmail's Issues

getmail error: exec command deliver failed

hi,

I set up the container and tried your example config with server and credentials for one of my mail accounts.
As i have problems connecting to dovecot, i ran getmail from container shell.

running the command getmail without any options returns
Error: default config/data dir "/root/.getmail/" does not exist

spcifiying my test user's dir with getmail --getmaildir=/home/test_user/.getmail runs into errors.
Seems like connectiong to external mail server works but forwarding messages to dovecot crashes.
command deliver 66 errors exec command deliver failed (refused to invoke external commands as root)

from my google research i understand that getmail (or dovecot?) should not be run as root due to security reasons.

Logging into the container as my test_user and running getmail or getmail --getmaildir=/home/test_user/.getmail returns
Error: default config/data dir "/test_user/.getmail/" does not exist

Additionally i can't check correct volume mapping cause cd /home returns can't cd to home.
As root in the container i can go into this directory.

how to connect to dovecot

Hallo,

and first of all thanks for this image. I hav been searching for a long time for a "personal mail archiv" like this.

I set up the container and created a getmail-account file for a tet mail address.
How can i connect to the dovecot server?

I can't find any point to enter dovecot user credentials or find preconfigured ones.

Thanks for help.

Rspamd with Træfik

is there any chance you can tell us how to integrate this with Rspamd ? with Træfik ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.