OCaml library to handle JMAP/IMAP email keywords (including Apple)
OCaml 84.0%
Standard ML 13.4%
Dune 0.8%
Other 1.8%
3 1 0

Clone this repository

https://tangled.org/anil.recoil.org/ocaml-mail-flag
git@git.recoil.org:anil.recoil.org/ocaml-mail-flag

For self-hosted knots, clone URLs may differ based on your setup.

README.md

mail-flag - Unified Message Flags for IMAP and JMAP#

Type-safe message keywords, system flags, and mailbox attributes for email protocols.

Key Features#

  • Unified keyword types: Standard, spam, extended, and Apple Mail flag color keywords
  • Protocol conversion: Seamless mapping between IMAP system flags and JMAP keywords
  • Mailbox attributes: LIST attributes and special-use roles (RFC 6154)
  • Apple Mail colors: 3-bit flag color encoding/decoding

Supported Standards#

Usage#

open Mail_flag

(* Parse keywords from IMAP or JMAP format *)
let seen = Keyword.of_string "\\Seen"    (* IMAP system flag *)
let junk = Keyword.of_string "$junk"     (* JMAP keyword *)

(* Convert between formats *)
let imap_str = Keyword.to_imap_string seen  (* "\\Seen" *)
let jmap_str = Keyword.to_string seen       (* "$seen" *)

(* Check keyword properties *)
let is_system = Keyword.is_standard seen    (* true *)
let exclusive = Keyword.is_mutually_exclusive `Junk `NotJunk  (* true *)

(* Work with mailbox attributes *)
let drafts = Mailbox_attr.of_string "\\Drafts"
let role = Mailbox_attr.to_jmap_role drafts  (* Some "drafts" *)

(* Apple Mail flag colors *)
let color = Flag_color.of_keywords [`MailFlagBit0; `MailFlagBit2]
(* color = Some `Purple *)

Installation#

opam install mail-flag

Documentation#

API documentation is available via:

opam install mail-flag
odig doc mail-flag

License#

ISC