Fetch IMAP messages by date range and/or by absolute count.
mailseq is read-only and driven by just two selection criteria:
:since/:before (via SentDateTerm) and :limit (via UID-range
optimisation or tail-of-result). The IMAP backend does not use
SEARCH FROM/TO/SUBJECT/… because those verbs are implemented
inconsistently across servers.
All functions return parsed Clojure maps (via
mailseq.parse/message->map).
Fetch IMAP messages by date range and/or by absolute count. mailseq is read-only and driven by just two selection criteria: `:since`/`:before` (via `SentDateTerm`) and `:limit` (via UID-range optimisation or tail-of-result). The IMAP backend does not use `SEARCH FROM/TO/SUBJECT/…` because those verbs are implemented inconsistently across servers. All functions return parsed Clojure maps (via `mailseq.parse/message->map`).
(by-uid conn folder-name uids)(by-uid conn folder-name uids opts)Fetch messages by their IMAP UIDs.
uids can be a single long or a collection of longs.
Returns a vector of message maps in the order of uids, skipping
unknown UIDs. One server round-trip.
Example: (by-uid conn "INBOX" 12345) (by-uid conn "INBOX" [12345 12346 12347])
Fetch messages by their IMAP UIDs. uids can be a single long or a collection of longs. Returns a vector of message maps in the order of `uids`, skipping unknown UIDs. One server round-trip. Example: (by-uid conn "INBOX" 12345) (by-uid conn "INBOX" [12345 12346 12347])
(by-uid-range conn folder-name start end)(by-uid-range conn folder-name start end opts)Fetch messages within a UID range [start, end] inclusive.
Use UIDFolder/LASTUID as end to fetch from start to the latest message.
Returns [] when no UID is in the range. If start is also beyond the
folder's UIDNEXT, logs a warning: UIDVALIDITY has most likely changed
and the caller resumes from a stale watermark. This is only a hint;
compare mailseq.imap.folder/uid-validity to detect it reliably.
Example: (by-uid-range conn "INBOX" 1000 2000) (by-uid-range conn "INBOX" 1000 UIDFolder/LASTUID)
Fetch messages within a UID range [start, end] inclusive. Use UIDFolder/LASTUID as end to fetch from start to the latest message. Returns [] when no UID is in the range. If `start` is also beyond the folder's UIDNEXT, logs a warning: UIDVALIDITY has most likely changed and the caller resumes from a stale watermark. This is only a hint; compare `mailseq.imap.folder/uid-validity` to detect it reliably. Example: (by-uid-range conn "INBOX" 1000 2000) (by-uid-range conn "INBOX" 1000 UIDFolder/LASTUID)
(list-uids conn folder-name)Return a vector of UID strings for every message in folder-name,
without fetching or parsing message content.
Opens the folder, retrieves all messages, and extracts their UIDs via a lightweight FetchProfile (UID only). Messages expunged in the meantime are skipped.
Return a vector of UID strings for every message in `folder-name`, without fetching or parsing message content. Opens the folder, retrieves all messages, and extracts their UIDs via a lightweight FetchProfile (UID only). Messages expunged in the meantime are skipped.
(messages conn folder-name)(messages conn folder-name opts)Fetch messages from a folder.
Selection options (combinable): :limit - maximum number of messages to return (most recent) :since - messages sent on/after this date (string or Date) :before - messages sent strictly before this date :headers? - include all headers in output (default: true) :body? - parse body content (default: true) :attachments? - include attachment byte data (default: true)
To fetch messages newer than a known UID, use by-uid-range.
Returns a vector of message maps.
Example: (messages conn "INBOX" {:limit 10}) (messages conn "INBOX" {:since "2025-01-01"})
Fetch messages from a folder.
Selection options (combinable):
:limit - maximum number of messages to return (most recent)
:since - messages sent on/after this date (string or Date)
:before - messages sent strictly before this date
:headers? - include all headers in output (default: true)
:body? - parse body content (default: true)
:attachments? - include attachment byte data (default: true)
To fetch messages newer than a known UID, use `by-uid-range`.
Returns a vector of message maps.
Example:
(messages conn "INBOX" {:limit 10})
(messages conn "INBOX" {:since "2025-01-01"})cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |