Debugging getmail #4344
-
My Getmail config is not working for some reason, I have no clue how to debug... Running
Generally speaking the config files are mounted into the container and look fine. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Use either |
Beta Was this translation helpful? Give feedback.
-
No, below is a full working example which functions fine on both v14 and v15 (presently As mentioned view the appropriate docs page for the image tag you're using due to the breaking change for getmail in DMS v15. DMS Getmail exampleCreate the yaml files, or manually combine them, run the commands below to verify. $ docker compose -f tls.compose.yaml run --rm gen-certs
$ docker compose up -d
# John has no mail in his inbox (Your local DMS instance with getmail)
$ docker compose exec -it dms-getmail doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=0
# Jane has no mail in her inbox (Your remote DMS instance)
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=0
# Send the remote DMS a mail internally (The PERMIT_DOCKER ENV allows to send this without authentication):
$ docker compose exec -it dms-remote swaks --server localhost --from [email protected] --to [email protected]
# Jane has mail now:
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=1
# Wait until the next getmail poll occurs, and check inboxes again.
# Getmail has retrieved Jane's mail, storing a copy at John's inbox:
$ docker compose exec -it dms-fetch doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=1
# As `delete = false` is the default in `/etc/getmailrc_general`,
# the mail is not deleted from Jane's mailbox:
$ docker compose exec -it dms-remote doveadm mailbox status -u [email protected] messages INBOX
INBOX messages=1 # dms.compose.yaml
services:
dms-getmail:
image: ghcr.io/docker-mailserver/docker-mailserver:latest # :14.0
hostname: mail.example.test
environment:
ENABLE_GETMAIL: 1
# We only change this setting to 1 minute for quicker testing:
GETMAIL_POLL: 1
# You'd normally use `volumes` here but for simplicity of the example, all config is contained within `compose.yaml`:
configs:
- source: dms-accounts-getmail
target: /tmp/docker-mailserver/postfix-accounts.cf
- source: getmail-jane
#target: /tmp/docker-mailserver/getmail/jane.cf # v15 has breaking change to path
target: /tmp/docker-mailserver/getmail-jane.cf # v14
dms-remote:
image: ghcr.io/docker-mailserver/docker-mailserver:latest # :14.0
hostname: mail.remote.test
environment:
# This is only used for testing as if mail had arrived via port 25 from another MTA,
# Allows for us send a test mail easily by trusting any mail client run within the container (like `swaks`):
PERMIT_DOCKER: container
configs:
- source: dms-accounts-remote
target: /tmp/docker-mailserver/postfix-accounts.cf
# Using the Docker Compose `configs.content` feature instead of volume mounting separate files.
# NOTE: This feature requires Docker Compose v2.23.1 (Nov 2023) or newer:
# https://github.com/compose-spec/compose-spec/pull/446
configs:
# Basic getmail config to retrieve mail from an account at another mail server via IMAP credentials:
getmail-jane:
content: |
[retriever]
type = SimpleIMAPSSLRetriever
server = mail.remote.test
username = [email protected]
password = secret
[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
allow_root_commands = true
arguments = ("-d","[email protected]")
# DMS requires an account to complete setup, provide one for each DMS instance:
# NOTE:
# - Both accounts are configured with the same password `secret` (SHA512-CRYPT hashed).
# - To opt-out of Docker Compose variable interpolation, `$` must be escaped as `$$`.
dms-accounts-getmail:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.
dms-accounts-remote:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8. The above will fail in this case since there's no cert configured and the # dms-tls.compose.yaml
volumes:
custom-certs:
name: tls-remote-test
external: true
services:
dms-getmail:
configs:
- source: dms-trust-custom-ca
target: /tmp/docker-mailserver/user-patches.sh
volumes:
- custom-certs:/tmp/custom-certs:ro
dms-remote:
environment:
SSL_TYPE: manual
SSL_CERT_PATH: /tmp/custom-certs/remote.test/cert.pem
SSL_KEY_PATH: /tmp/custom-certs/remote.test/key.pem
volumes:
- custom-certs:/tmp/custom-certs:ro
# Copy the root CA cert to a location that `update-ca-certificates` command will install it:
# Alternatively use the long syntax for volumes to mount directly by `subpath`,
# But you will still need to run `update-ca-certificates`.
configs:
dms-trust-custom-ca:
content: |
#!/bin/bash
cp /tmp/custom-certs/ca/cert.pem /usr/local/share/ca-certificates/smallstep-ca.crt
update-ca-certificates # compose.yaml
# Alternative to using the CLI 'merge' syntax with `-f`:
# docker compose -f dms.compose.yaml -f dms-tls.compose.yaml up
# https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/
# https://docs.docker.com/reference/compose-file/merge/
# https://docs.docker.com/compose/how-tos/multiple-compose-files/include/
# https://docs.docker.com/reference/compose-file/include/
include:
- path:
- dms.compose.yaml
- dms-tls.compose.yaml As per the last YAML snippet, you can either specify separate compose files via CLI or in a
Certificate provision example (run this first)To compliment the # tls.compose.yaml
# Named data volume for sharing with other compose projects:
# NOTE: For production use, your services would volume mount with `subpath` (requires long syntax):
# https://docs.docker.com/reference/compose-file/services/#volumes
volumes:
custom-certs:
name: tls-remote-test
services:
gen-certs:
image: smallstep/step-ca
# `smallstep/step-ca` by default runs as non-root (1000:1000),
# change to the desired UID/GID ownership of certs generated:
user: root
# Persist certs externally:
volumes:
- custom-certs:/tmp/certs/:rw
working_dir: /tmp/certs
# Support for running the custom script below:
entrypoint: /tmp/generate-certs.sh
configs:
- source: generate-certs
target: /tmp/generate-certs.sh
# Make script executable:
mode: 500
configs:
generate-certs:
content: |
#!/usr/bin/env bash
# Store root CA and leaf certs in separate directories:
mkdir -p ca remote.test
# NOTE: Append the `--force` option to both commands below if you want to run this
# script multiple times, such as with services using `depends_on: [ gen-certs ]`
step certificate create 'Smallstep Root CA' ca/cert.pem ca/key.pem \
--profile root-ca --no-password --insecure
step certificate create 'Smallstep Leaf' remote.test/cert.pem remote.test/key.pem \
--san 'mail.remote.test' \
--ca ca/cert.pem --ca-key ca/key.pem \
--profile leaf --no-password --insecure This could be saved as say Troubleshooting logIn the example above, without When cron fails due to an error while performing the task, it'll send an email to the system user Full log during this event
In DMS v15, this cron job is changed to a a supervisord service instead which has a bash script loop the polling task. The DMS v15 change will thus make the failure even more silent, not sure if @casperklein wants to look into that With this example we have the following: $ docker compose -f dms.compose.yaml up --force-recreate -d
$ docker compose -f dms.compose.yaml exec -it dms-getmail bash
$ getmail --getmaildir /var/lib/getmail --rcfile /etc/getmailrc.d/jane
jane: socket error ([Errno 111] Connection refused)
$ echo $?
127
$ cat /var/log/supervisor/getmail.log
jane: socket error ([Errno 111] Connection refused)
jane: socket error ([Errno 111] Connection refused)
jane: socket error ([Errno 111] Connection refused) So I guess that's fine, the stderr is logged in it's new service log file, the user just needs to check it. |
Beta Was this translation helpful? Give feedback.
-
I found that its helpful to make an override to the default general getmail config to make it more "talkative"
|
Beta Was this translation helpful? Give feedback.
No, below is a full working example which functions fine on both v14 and v15 (presently
:edge
) of DMS.As mentioned view the appropriate docs page for the image tag you're using due to the breaking change for getmail in DMS v15.
DMS Getmail example
Create the yaml files, or manually combine them, run the commands below to verify.