1
1
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-12-18 23:14:11 +01:00
docker-mailserver/docs/content/config/advanced/mail-getmail.md
Casper b2978fd760
breaking: Refactor getmail support (#4156)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-08-17 12:14:59 +02:00

3.7 KiB

title
Advanced | Email Gathering with Getmail

To enable the getmail service to retrieve e-mails set the environment variable ENABLE_GETMAIL to 1. Your compose.yaml file should include the following:

environment:
  - ENABLE_GETMAIL=1
  - GETMAIL_POLL=5

In your DMS config volume (eg: docker-data/dms/config/), add a subdirectory getmail/ for including your getmail config files (eg: imap-example.cf) for each remote account that you want to retrieve mail from and deliver to the mailbox of a DMS account.

The content of these config files is documented in the next section with an IMAP and POP3 example to reference.

The directory structure should look similar to this:

├── docker-data/dms/config
│   ├── dovecot.cf
│   ├── getmail
│   │   ├── getmailrc_general.cf
│   │   ├── remote-account1.cf
│   │   ├── remote-account2.cf
│   ├── postfix-accounts.cf
│   └── postfix-virtual.cf
├── docker-compose.yml
└── README.md

Configuration

A detailed description of the configuration options can be found in the online version of the manual page.

Common Options

The default options added to each getmail config are:

[options]
verbose = 0
read_all = false
delete = false
max_messages_per_session = 500
received = false
delivered_to = false

The DMS integration for Getmail generates a getmailrc config that prepends the common options of the base config to each remote account config file (*.cf) found in the DMS Config Volume getmail/ directory.

!!! tip "Change the base options"

Add your own base config as `getmail/getmailrc_general.cf` into the DMS Config Volume. It will replace the DMS defaults shown above.

??? example "IMAP Configuration"

This example will:

1. Connect to the remote IMAP server from Gmail.
2. Retrieve mail from the gmail account `alice` with password `notsecure`.
3. Store any mail retrieved from the remote mail-server into DMS for the `user1@example.com` account that DMS manages.

```getmailrc
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
username = alice
password = notsecure
[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
allow_root_commands = true
arguments =("-d","user1@example.com")
```

??? example "POP3 Configuration"

Just like the IMAP example above, but instead via POP3 protocol if you prefer that over IMAP.

```getmailrc
[retriever]
type = SimplePOP3SSLRetriever
server = pop3.gmail.com
username = alice
password = notsecure
[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
allow_root_commands = true
arguments =("-d","user1@example.com")
```

Polling Interval

By default the getmail service checks external mail accounts for new mail every 5 minutes. That polling interval is configurable via the GETMAIL_POLL ENV variable, with a value in minutes (default: 5, min: 1):

environment:
  - GETMAIL_POLL=1

XOAUTH2 Authentication

It is possible to utilize the getmail-gmail-xoauth-tokens helper to provide authentication using xoauth2 for gmail (example 12) or Microsoft Office 365 (example 13)