From 393cfd40609fa8ee654f0d561d176c14cad3955d Mon Sep 17 00:00:00 2001 From: ml Date: Mon, 29 Jun 2026 21:25:35 +0200 Subject: [PATCH] Fix fetchmail syntax errors for fetchmail 6.6.x on Alpine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fetchmailrc.j2: - Move `ssl` to user section (inline after password); in 6.6.x it is a user-level keyword, not a server-level one — placing it after `proto pop3` caused 'unexpected USERNAME at user' syntax error - Move `interval` before user section (it is server-level) - Replace `smtphost dovecot` + `smtpport 24` with `smtphost dovecot/24`; `smtpport` is not a valid rcfile keyword in 6.6.x — port must be given as host/port in the smtphost value dovecot.conf.j2: - Add `auth_username_format = %Ln` to protocol lmtp block so that the LMTP recipient address `ml@dovecot` (appended by fetchmail) is stripped to just `ml` for userdb lookup --- ansible/roles/mail/templates/dovecot.conf.j2 | 5 +++++ ansible/roles/mail/templates/fetchmailrc.j2 | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ansible/roles/mail/templates/dovecot.conf.j2 b/ansible/roles/mail/templates/dovecot.conf.j2 index 64f12f3..8919d14 100644 --- a/ansible/roles/mail/templates/dovecot.conf.j2 +++ b/ansible/roles/mail/templates/dovecot.conf.j2 @@ -39,5 +39,10 @@ service lmtp { } } +# Strip domain from LMTP recipient so fetchmail's "ml@dovecot" resolves to user "ml" +protocol lmtp { + auth_username_format = %Ln +} + # SSL disabled — Traefik handles TLS ssl = no diff --git a/ansible/roles/mail/templates/fetchmailrc.j2 b/ansible/roles/mail/templates/fetchmailrc.j2 index b88c326..785fa26 100644 --- a/ansible/roles/mail/templates/fetchmailrc.j2 +++ b/ansible/roles/mail/templates/fetchmailrc.j2 @@ -6,15 +6,14 @@ set logfile /dev/stdout set daemon 60 {% for account in fetchmail_accounts | default([]) %} -poll {{ account.server }} proto {{ account.protocol | default('pop3') }}{% if account.ssl | default(true) %} ssl{% endif %} +poll {{ account.server }} proto {{ account.protocol | default('pop3') }} + interval {{ account.poll_minutes | default(10) }} + user "{{ account.username }}" password "{{ account.password }}"{% if account.ssl | default(true) %} ssl{% endif %} - user "{{ account.username }}" password "{{ account.password }}" is {{ account.local_user }} here - smtphost dovecot - smtpport 24 + smtphost dovecot/24 lmtp fetchall {{ 'keep' if account.keep | default(true) else 'no keep' }} - interval {{ account.poll_minutes | default(10) }} {% endfor %}