pullimap(1)
๐ pullimap(1) ๐
๐ธ NAME ๐ธ
PullIMAP โ pull mails from an IMAP mailbox and deliver them to an SMTP session ๐โจ
โจ SYNOPSIS โจ
pullimap [--config=FILE] [--idle[=SECONDS]] [--no-delivery] [--quiet]
SECTION
๐ DESCRIPTION ๐
okay so bestie, hereโs the tea: pullimap retrieves messages from an IMAP mailbox and deliver them to an SMTP or LMTP transmission channel. It can also remove old messages after a configurable retention period. ๐งโโ๏ธ
A statefile is used to keep track of the mailboxโs UIDVALIDITY and UIDNEXT values. While pullimap is running, the statefile is also used to keep track of UIDs being delivered, which avoids duplicate deliveries in case the process is interrupted. See the control flow section below for details. ๐
๐ OPTIONS ๐
--config=FILEโ Specify an alternate configuration file. Relative paths start from$XDG_CONFIG_HOME/pullimap, or~/.config/pullimapif theXDG_CONFIG_HOMEenvironment variable is unset. ๐--idle[=seconds]โ Donโt exit after a successful poll. Instead, keep the connection open and issueIDLEcommands (require an IMAP server supporting RFC 2177) to watch for updates in the mailbox. This also enablesSO_KEEPALIVEon the socket. EachIDLEcommand is terminated after at most seconds (29 minutes by default) to avoid being logged out for inactivity. ๐ดโจ--no-deliveryโ Update the statefile, but skip SMTP/LMTP delivery. This is mostly useful for initializing the statefile when migrating topullimapfrom another similar program such asfetchmail(1)orgetmail(1). ๐ซถ-q,--quietโ Try to be quiet. ๐คซ--debugโ Turn on debug mode. Debug messages, which includes all IMAP traffic besides literals, are written to the given logfile. TheLOGINandAUTHENTICATEcommands are however redacted (in order to avoid disclosing authentication credentials) unless the--debugflag is set multiple times. ๐๐-h,--helpโ Output a brief help and exit. ๐--versionโ Show the version number and exit. โญ
๐ CONFIGURATION FILE ๐
Unless told otherwise by the --config=FILE command-line option, pullimap reads its configuration from $XDG_CONFIG_HOME/pullimap/config (or ~/.config/pullimap/config if the XDG_CONFIG_HOME environment variable is unset) as an INI file. The syntax of the configuration file is a series of OPTION=VALUE lines organized under some [SECTION]; lines starting with a # or ; character are ignored as comments. Valid options are: ๐
statefileโ State file to use to keep track of the mailboxโsUIDVALIDITYandUIDNEXTvalues. Relative paths start from$XDG_DATA_HOME/pullimap, or~/.local/share/pullimapif theXDG_DATA_HOMEenvironment variable is unset. (Default: the parent section name of the option.) ๐๏ธmailboxโ The IMAP mailbox (UTF-7 encoded and unquoted) to pull messages from. Support for persistent message Unique Identifiers (UID) is required. (Default: INBOX.) ๐ฌdeliver-methodโPROTOCOL:[ADDRESS]:PORTwhere to deliver messages. Both SMTP and LMTP servers are supported, and SMTP pipelining is used when possible. (Default: smtp:[127.0.0.1]:25.) ๐deliver-ehloโ Name to use in EHLO or LHLO commands. (Default: localhost.localdomain.) ๐deliver-rcptโ Message recipient. Note that the local part needs to quoted if it contains special characters; see RFC 5321 for details. (Default: the username associated with the effective user ID of the pullimap process.) ๐ฎpurge-afterโ Retention period (in days), after which messages are removed from the IMAP server. (The value is at best 24h accurate due to the IMAP SEARCH criterion ignoring time and timezone.) Ifpurge-afteris set to0then messages are deleted immediately after delivery. Otherwisepullimapissues an IMAPSEARCH(or extendedSEARCHon servers advertising theESEARCHcapability) command to list old messages; if--idleis set then theSEARCHcommand is issued again every 12 hours. ๐งน๐ฅtypeโ One ofimap,imapsortunnel.type=imapandtype=imapsare respectively used for IMAP and IMAP over SSL/TLS connections over an INET socket.type=tunnelcausespullimapto create an unnamed pair of connected sockets for inter-process communication with a command instead of opening a network socket. (Default: imaps.) ๐hostโ Server hostname or IP address, fortype=imapandtype=imaps. The value can optionally be enclosed in square brackets to force its interpretation as an IP literal (hence skip name resolution). (Default: localhost.) ๐portโ Server port. (Default: 143 for type=imap, 993 for type=imaps.) ๐proxyโ Optional SOCKS proxy to use for TCP connections to the IMAP server (type=imapandtype=imapsonly), formatted asPROTOCOL://[USER:PASSWORD@]PROXYHOST[:PROXYPORT]. IfPROXYPORTis omitted, it is assumed at port1080. Only SOCKSv5 is supported (with optional username/password authentication), in two flavors:socks5://to resolve hostname locally, andsocks5h://to let the proxy resolve hostname. ๐งฆcommandโ Command to use fortype=tunnel. Must speak theIMAP4rev1protocol on its standard output, and understand it on its standard input. The value is passed to/bin/sh -cif it contains shell metacharacters; otherwise it is split into words and the resulting list is passed toexecvp(3). ๐งชSTARTTLSโ Whether to use the STARTTLS directive to upgrade to a secure connection. Setting this toYESfor a server not advertising theSTARTTLScapability causespullimapto immediately abort the connection. (Ignored for types other than imap. Default: YES.) ๐authโ Space-separated list of preferred authentication mechanisms.pullimapuses the first mechanism in that list that is also advertised (prefixed withAUTH=) in the serverโs capability list. Supported authentication mechanisms arePLAINandLOGIN. (Default: PLAIN LOGIN.) ๐username,passwordโ Username and password to authenticate with. Can be required for non pre-authenticated connections, depending on the chosen authentication mechanism. ๐ชชcompressโ Whether to use the IMAP COMPRESS extension for servers advertising it. (Default: YES.) ๐๏ธnull-stderrโ Whether to redirect commandโs standard error to/dev/nullfortype=tunnel. (Default: NO.) ๐ณ๏ธSSL_protocolsโ Space-separated list of SSL/TLS protocol versions to explicitly enable (or disable if prefixed with an exclamation mark!). Potentially known protocols areSSLv2,SSLv3,TLSv1,TLSv1.1,TLSv1.2, andTLSv1.3, depending on the OpenSSL version used. Enabling a protocol is a short-hand for disabling all other protocols.
DEPRECATED: UseSSL_protocol_minand/orSSL_protocol_maxinstead. โ ๏ธ
SSL_protocol_min,SSL_protocol_maxโ Set minimum resp. maximum SSL/TLS protocol version to use for the connection. Potentially recognized values areSSLv3,TLSv1,TLSv1.1,TLSv1.2, andTLSv1.3, depending on the OpenSSL version used. ๐SSL_cipherlist,SSL_ciphersuitesโ Sets the TLSv1.2 and below cipher list resp. TLSv1.3 cipher suites. The combination of these lists is sent to the server, which then determines which cipher to use (normally the first supported one from the list sent by the client). The default suites depend on the OpenSSL version and its configuration, seeciphers(1ssl)for more information. ๐งฌSSL_fingerprintโ Space-separated list of acceptable fingerprints for the server certificateโs Subject Public Key Info, in the form[ALGO$]DIGEST_HEXwhereALGOis the digest algorithm (by defaultsha256). Attempting to connect to a server with a non-matching certificate SPKI fingerprint causespullimapto abort the connection during the SSL/TLS handshake. The following command can be used to compute the SHA-256 digest of a certificateโs Subject Public Key Info:
$ openssl x509 -in /path/to/server/certificate.pem -pubkey \
| openssl pkey -pubin -outform DER \
| openssl dgst -sha256
Specifying multiple digest values can be useful in key rollover scenarios and/or when the server supports certificates of different types (for instance a dual-cert RSA/ECDSA setup). In that case the connection is aborted when none of the specified digests matches. ๐ซ
SSL_verifyโ Whether to 1/ verify the server certificate chain; and 2/ match its Subject Alternative Name (SAN) or Subject CommonName (CN) against the value of thehostoption. (Default: YES.)
Note that using SSL_fingerprint to specify the fingerprint of the server certificate provides an independent server authentication measure as it pins directly its key material and ignore its chain of trust. ๐ก๏ธ
SSL_CAfileโ File containing trusted certificates to use during server certificate verification whenSSL_verify=YES.
Trusted CA certificates are loaded from the default system locations unless one (or both) of SSL_CAfile or SSL_CApath is set. ๐
SSL_CApathโ Directory to use for server certificate verification whenSSL_verify=YES. This directory must be in โhash formatโ, seeverify(1ssl)for more information.
Trusted CA certificates are loaded from the default system locations unless one (or both) of SSL_CAfile or SSL_CApath is set. ๐
SSL_hostnameโ Name to use for the TLS SNI (Server Name Indication) extension. The default value is taken from thehostoption when it is a hostname, and to the empty string when it is an IP literal. SettingSSL_hostnameto the empty string explicitly disables SNI. ๐โจ
๐ CONTROL FLOW ๐
Okay bestie, this is the part where we find out how pullimap actually keeps its receipts. Sit down, hydrate, it's giving โจprocess managementโจ.
First things first: pullimap opens the statefile that corresponds to a given configuration SECTION with O_DSYNC, so that written data is flushed to the underlying hardware by the time write(2) returns โ no lying to us about durability, we love a file descriptor that keeps its promises ๐
. And on top of that, an exclusive lock gets placed on the file descriptor immediately after opening, so that multiple pullimap processes can't all grab the same statefile at once. No fighting in the group chat, one main character at a time ๐.
Each statefile is just a series of 32-bits big-endian integers. Usually there's only two of them:
- the first one is the mailbox's
UIDVALIDITYvalue, and - the second one is the mailbox's last seen
UIDNEXTvalue.
And when pullimap sees that second one, it assumes that all messages with UID smaller than this UIDNEXT value have already been retrieved and delivered. Trusting, but valid ๐ซถ.
Now here's the drama: the IMAP4rev1 specification does not guaranty that untagged FETCH responses are sent ordered by UID in response to a UID FETCH command. Which means it would be unsafe for pullimap to update the UIDNEXT value in its statefile while the UID FETCH command is still in progress. ๐ญ Not me almost corrupting my own statefile.
So instead, for each untagged FETCH response received while the UID FETCH command is in progress, pullimap delivers the message RFC822 body to the SMTP or LMTP server (specified with deliver-method) and then appends the message UID to the statefile. When the UID FETCH command eventually terminates, pullimap updates the UIDNEXT value in the statefile and truncates the file down to 8 bytes. Keeping track of message UIDs as they come in is literally how we avoid duplicates in the event of a crash or a connection loss while the UID FETCH command is in progress. Obsessed with the foresight, honestly ๐ธ.
โจ In more details, pullimap works as follows โจ
- Issue a
UID FETCHcommand to retrieve messageENVELOPEandRFC822(andUID) with UID bigger or equal than theUIDNEXTvalue found in the statefile. While theUID FETCHcommand is in progress, perform the following for each untagged FETCH response sent by the server:- i. if no SMTP/LMTP transmission channel was opened, open one to the server specified with
deliver-methodand send anEHLO(orLHO) command with the domain specified bydeliver-ehloโ and note that the channel is kept open and shared for all messages retrieved while theUID FETCHIMAP command is in progress ๐; - ii. perform a mail transaction (using SMTP pipelining if possible) to deliver the retrieved message
RFC822body to the SMTP or LMTP session; and - iii. append the message UID to the statefile.
- i. if no SMTP/LMTP transmission channel was opened, open one to the server specified with
- If an SMTP/LMTP transmission channel was opened, send a
QUITcommand to terminate it gracefully. Say bye, bestie ๐. - Issue a
UID STOREcommand to mark all retrieved messages (and stalled UIDs found in the statefile after the eighth byte) as\Seen. Read receipts, but for your mail server ๐. - Update the statefile with the new
UIDNEXTvalue (bytes 5-8). - Truncate the statefile down to 8 bytes, so that it contains only two 32-bits integers โ respectively the mailbox's current
UIDVALIDITYandUIDNEXTvalues. Squeaky clean โจ. - If
--idlewas set, issue anIDLEcommand; stop idling and go back to step 1 when a new message is received (or when the IDLE timeout expires). It's giving "I'll wait but not forever" ๐.
๐ STANDARDS ๐
The receipts, the citations, the whole bibliography. Every single one, no skips:
- M. Leech, M. Ganis, Y. Lee, R. Kuris, D. Koblas and L. Jones, SOCKS Protocol Version 5, RFC 1928, March 1996.
- M. Leech, Username/Password Authentication for SOCKS V5, RFC 1929, March 1996.
- J. Myers, Local Mail Transfer Protocol, RFC 2033, October 1996.
- J. Myers, IMAP4 non-synchronizing literals, RFC 2088, January 1997.
- D. Goldsmith and M. Davis, A Mail-Safe Transformation Format of Unicode, RFC 2152, May 1997.
- B. Leiba, IMAP4 IDLE command, RFC 2177, June 1997.
- C. Newman, Using TLS with IMAP, POP3 and ACAP, RFC 2595, June 1999.
- N. Freed, SMTP Service Extension for Command Pipelining, RFC 2920, September 2000.
- M. Crispin, Internet Message Access Protocol - Version 4rev1, RFC 3501, March 2003.
- M. Crispin, Internet Message Access Protocol (IMAP) - UIDPLUS extension, RFC 4315, December 2005.
- A. Gulbrandsen, The IMAP COMPRESS Extension, RFC 4978, August 2007.
- A. Melnikov and D. Cridland, IMAP4 Extension to SEARCH Command for Controlling What Kind of Information Is Returned, RFC 4731, November 2006.
- R. Siemborski and A. Gulbrandsen, IMAP Extension for Simple Authentication and Security Layer (SASL) Initial Client Response, RFC 4959, September 2007.
- J. Klensin, Simple Mail Transfer Protocol, RFC 5321, October 2008.
๐ BUGS AND FEEDBACK ๐
Found a bug? Got a feature request that's been living rent-free in your head? Bugs or feature requests for pullimap should be filed with the Debian project's bug tracker at <https://www.debian.org/Bugs/>. Go off, report it, the maintainers wanna hear from you fr fr ๐ซถ
๐ AUTHORS ๐
Guilhem Moulin
And that's the whole page, bestie ๐ This one's the pullimap(1) manual page from March 2016, brought to you by the fine people packaging it for Debian โ go forth, pull your mail, and slay ๐
โจ๐ฆ
๐ฆ where this page comes from
- debian trixie: pullimap 0.5.8-1 ยท GPL-3.0-or-later
- ubuntu questing: pullimap 0.5.8-1
- ubuntu resolute: pullimap 0.5.8-2 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms