Repository navigation
Conversation
The image's copy was PostfixAdmin's ADDITIONS/fetchmail.pl from 2016, plus two local changes: the config file path and the database port. This takes upstream's script at a2ee929, the latest commit to touch it, and keeps those two changes. a2ee929 is newer than PostfixAdmin 4.0.6; 4.0.5 and 4.0.6 ship the same script without its SQLite lines. Upstream has since added escaping for " and \ in source passwords, "dovecot" as an mda keyword, the src_port column, --pidfile in place of -i (fetchmail's id file), a configurable lock directory, and SQLite support. The SQLite path is unreachable here: fetchmail.conf only sets mysql or Pg, and on those the SQL is unchanged. - setup.sh creates /var/lock/fetchmail, upstream's lock directory. The script exits if it is missing. - The test schemas gain src_port, as PostfixAdmin's upgrade 1843 adds it (PostfixAdmin 3.3.0 and later). The script now selects it. - reverse.bats gains three tests that run the script as cron does: delivery through port 10025, mda dovecot, and a password with " and \.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What fetchmail is and what this image uses it for
fetchmail is a mail retrieval client. It logs in to a mailbox on another server over POP3 or IMAP, downloads the messages, and hands them to the local mail system for delivery. This image runs it to pull mail from mailboxes elsewhere into mailboxes on this server at regular intervals (README feature list: "fetch emails from external IMAP/POP3 server into local mailbox"). For example, a user who has moved here can keep receiving the mail that still arrives at their old provider's mailbox.
What to fetch is not configured in this image. The jobs are defined in PostfixAdmin, the web administration interface, which runs as a separate container (the
mailserver2/postfixadminimage) and writes to the same database this image reads its domains and mailboxes from. PostfixAdmin only stores the jobs. This image does the fetching. The feature is off by default, and works like this:keepandfetchall, how often to poll, and the local mailbox to deliver into. Each job is a row in thefetchmailtable of the shared database.ENABLE_FETCHMAIL=true, the image installs a cron entry that runs/usr/local/bin/fetchmail.plas root everyFETCHMAIL_INTERVALminutes (default 10). PostfixAdmin publishes this script in its source tree, asADDITIONS/fetchmail.pl, for whichever host runs fetchmail. This image keeps a copy with two local changes: it reads its database settings from/etc/postfixadmin/fetchmail.conf, whichsetup.shfills in fromDBDRIVER,DBHOST,DBPORT,DBNAME,DBUSERandDBPASS, and it addsDBPORTto the connection string.fetchmailon it, and stores the time of the run back in the job's row.localhost, or through a command named in the job'smdafield. On port 25, Postfix'sreject_sender_login_mismatchrefuses fetched mail whose sender is an address on this server, because the client hasn't logged in (553 ... not logged in). Sosetup.shalso adds an SMTP listener on127.0.0.1:10025with fewer restrictions when fetchmail is enabled (Fetchmail fails to deliver mails from a local sender hardware/mailserver#276). A job uses it withsmtp localhost/10025in its extra options. The listener is bound to the container's loopback interface and accepts mail only from loopback clients (mynetworks=127.0.0.0/8,[::1]/128, thenreject). Docker forwards a published port to the container's network interface, not to its loopback, so publishing 10025 would not make it reachable from outside.What is the current behavior (you can also link to an open issue here) ?
The image's
fetchmail.plis upstream483bb83from August 2016 plus the two local changes. It misses every upstream fix since. For example, it puts the source password into fetchmail's configuration without escaping, and a test password with"and\in it,pa"ss\word, fails to log in. It also ignores a job's port, and it has nodovecotkeyword for themdafield.What is the new behavior (if this is a feature change) ?
fetchmail.plis upstream's current script,a2ee929(2026-11-12) on PostfixAdmin'smaster, plus the same two local changes. Upstream's changes to the file since 2016:src_portcolumn (d35e668,594a847, fetchmail.pl $src_port implementation incomplete postfixadmin/postfixadmin#784)./var/lock/fetchmailby default, and the script stops if that directory is missing (f871365,8f20c96, fetchmail.pl create a lock file inside /var/run instead of /var/lock postfixadmin/postfixadmin#101).dovecotin a job'smdafield delivers through Dovecot's LDA,/usr/lib/dovecot/deliver -d <mailbox>(352ae80,416a71d).--pidfile. The old script passed it with-i, which names fetchmail's UID state file instead (78174d8, Fetchmail seen mails state reset after reboot postfixadmin/postfixadmin#681)."and\in the source password (ecdd40c, Fetchmail authentication fails when special characters in password postfixadmin/postfixadmin#782).a2ee929). This path can't be reached in this image, becausefetchmail.confonly sets a database type formysqlandpgsql. The same commit putsnow()in a variable for the SQL that stores the poll time. On MySQL and PostgreSQL the variable isnow(), so the statement is the same as before.This copy comes from
a2ee929, which is on PostfixAdmin'smasterbut is newer than their latest release at the time of writing, v4.0.6 (2026-11-06). v4.0.5 and v4.0.6 ship the samefetchmail.pl, which differs from this one only by the SQLite lines.Changes in the image to go with it:
setup.shcreates/var/lock/fetchmailinstead of/var/run/fetchmail. Without it, the script logsPlease create: /var/lock/fetchmailand exits.src_port, as PostfixAdmin's database upgrade 1843 adds it.Compatibility: the script now selects
src_port, which PostfixAdmin first shipped in 3.3.0 (January 2021). On an older schema the query fails. I checked what happens then: the error goes to stderr, which the cron entry discards, the script exits 0, and syslog shows nothing. Fetch jobs stop without any message. Themailserver2/postfixadminimage is 4.0.5, so it has the column.Note: rspamd and Zeyple are attached to Postfix, rspamd as a milter and Zeyple as a
content_filter. Mail that fetchmail delivers through port 10025 doesn't pass through either, because that listener setsno_miltersand clearscontent_filter. Mail delivered withmda dovecotdoesn't either, because it goes straight to Dovecot's LDA. This PR doesn't change that: the old script worked the same way with the LDA command written out inmda. (This is from the configuration; I haven't tested it.)Type of change
Status
Todo List
How has this been tested ?
Only the
reversesuite enables fetchmail, so the new tests are there, on PostgreSQL. They run the script the way cron does, against a job that fetchesjohn.doe@domain.tld's INBOX from this server over IMAP intosarah.connor@domain.tld.smtp localhost/10025withsrc_port143, and checks the job's poll time was updated.mda dovecotand checks that Dovecot's LDA logged saving each one.pa"ss\word, fetches from it, and checks that the login succeeded and noAuthorization failurewas logged./var/lock/fetchmail, all three fail.defaultcontainer: a job runs only once its poll interval has elapsed,src_portandDBPORTare used, and delivery through the LDA works. This was done with v4.0.5's script. On MySQL, this branch's script sends the same SQL.1d30a54), 361/361: default 139, reverse 88, ldap 66, ldap2 30, sieve 2, ecdsa 4, traefik_acmev1 11, traefik_acmev2 12, traefik_v3 9.