Pure functions for IMAP message parsing. No I/O, no side effects.
Pure functions for IMAP message parsing. No I/O, no side effects.
(attachment-part? {:keys [content-type disposition filename]})True when a leaf MIME part is an attachment rather than body text: it has Content-Disposition attachment, a filename, or is not text/plain or text/html. A text/plain .txt or .csv file is an attachment, never the body.
Args: part - {:content-type string :disposition string-or-nil :filename string-or-nil}
True when a leaf MIME part is an attachment rather than body text: it has
Content-Disposition attachment, a filename, or is not text/plain or text/html.
A text/plain .txt or .csv file is an attachment, never the body.
Args:
part - {:content-type string :disposition string-or-nil :filename string-or-nil}(base-content-type content-type)Lower-cased media type without parameters: "text/plain; charset=UTF-8" → "text/plain".
Lower-cased media type without parameters: "text/plain; charset=UTF-8" → "text/plain".
(build-attachment {:keys [content-type filename disposition content-id]}
content)InboundAttachment map for an attachment part and its decoded bytes. :disposition and :content-id are left out when the part has no such header.
InboundAttachment map for an attachment part and its decoded bytes. :disposition and :content-id are left out when the part has no such header.
(build-inbound-message uid from to subject body-parts received-at headers)Construct an InboundMessage map from IMAP message fields.
Args: uid - long, IMAP UID from - string, sender address to - vector of strings subject - string body-parts - seq of {:content-type :content} received-at - java.util.Date or inst? headers - string-keyed header map (will be converted to kebab keywords)
Returns: InboundMessage map
Construct an InboundMessage map from IMAP message fields.
Args:
uid - long, IMAP UID
from - string, sender address
to - vector of strings
subject - string
body-parts - seq of {:content-type :content}
received-at - java.util.Date or inst?
headers - string-keyed header map (will be converted to kebab keywords)
Returns:
InboundMessage map(extract-body-text parts)Extract plain text and HTML from a sequence of body parts. The first part of each type wins.
Args: parts - sequence of {:content-type string :content string} content-type is checked for "text/plain" and "text/html"
Returns: {:text "..." :html "..."} — either or both may be nil
Extract plain text and HTML from a sequence of body parts. The first part of
each type wins.
Args:
parts - sequence of {:content-type string :content string}
content-type is checked for "text/plain" and "text/html"
Returns:
{:text "..." :html "..."} — either or both may be nil(mark-embedded body-parts attachments)Set :embedded? on each attachment: true when an HTML body part shows it by cid:, as with a signature logo, rather than the sender attaching it. Disposition alone does not tell: some clients send real attachments inline. Every text/html part is read, since Apple Mail splits the body around images.
Set :embedded? on each attachment: true when an HTML body part shows it by cid:, as with a signature logo, rather than the sender attaching it. Disposition alone does not tell: some clients send real attachments inline. Every text/html part is read, since Apple Mail splits the body around images.
(message-summary msg)Return a concise summary of a single InboundMessage.
Returns: {:uid :from :subject :received-at :seen?}
Return a concise summary of a single InboundMessage.
Returns:
{:uid :from :subject :received-at :seen?}(parse-message-headers header-map)Convert a string-keyed header map to kebab-case keyword keys.
Args: header-map - map of {"Header-Name" "value"}
Returns: map of {:header-name "value"}
Convert a string-keyed header map to kebab-case keyword keys.
Args:
header-map - map of {"Header-Name" "value"}
Returns:
map of {:header-name "value"}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 |