···5555 a cross reference URL where relevant by linking to a URL of the form
5656 "https://datatracker.ietf.org/doc/html/rfc8620#section-1.1" for the online
5757 version of the RFCs stored in specs/
5858-14. Add an ocamldoc-format tutorial on how to use the library to index.mld along with cross references
5858+14. DONE. Add an ocamldoc-format tutorial on how to use the library to index.mld along with cross references
5959 into the various libraries. Put corresponding executable files into bin/ so that they can be
6060 build tested and run as well. Assume the pattern of the JMAP_API_TOKEN environment variable being
6161 set can be counted on to be present when they are run.
6262+15. Add a README.md to this repository that describes what this is. Note explicitly in the
6363+ README that this is largely an AI-generated interface and has not been audited carefully.
+3-83
README.md
···11# JMAP OCaml Client
2233-A type-safe OCaml interface to the JMAP protocol ([RFC8620](https://datatracker.ietf.org/doc/html/rfc8620)) and JMAP Mail extension ([RFC8621](https://datatracker.ietf.org/doc/html/rfc8621)).
33+An OCaml interface to the JMAP protocol ([RFC8620](https://datatracker.ietf.org/doc/html/rfc8620)) and JMAP Mail extension ([RFC8621](https://datatracker.ietf.org/doc/html/rfc8621)).
4455**Note:** This library is largely AI-generated and has not been audited carefully. It's a proof-of-concept implementation of the JMAP specification.
66···1919Add to your project with opam:
20202121```
2222-opam install jmap
2323-```
2424-2525-Or pin the development version:
2626-2727-```
2828-opam pin add jmap.dev git+https://github.com/example/jmap-ocaml.git
2929-```
3030-3131-## Quick Start
3232-3333-```ocaml
3434-open Lwt.Syntax
3535-open Jmap
3636-open Jmap_mail
3737-3838-(* Authentication *)
3939-let token = Sys.getenv "JMAP_API_TOKEN" in
4040-let* result = Jmap_mail.login_with_token
4141- ~uri:"https://api.fastmail.com/jmap/session"
4242- ~api_token:token
4343-in
4444-4545-match result with
4646-| Error err ->
4747- Printf.eprintf "Authentication failed\n";
4848- exit 1
4949-5050-| Ok conn ->
5151- (* Get primary account ID *)
5252- let mail_capability = Jmap_mail.Capability.to_string Jmap_mail.Capability.Mail in
5353- let account_id = List.assoc mail_capability conn.session.primary_accounts in
5454-5555- (* Get mailboxes *)
5656- let* mailboxes_result = Jmap_mail.get_mailboxes conn ~account_id in
5757-5858- match mailboxes_result with
5959- | Error err ->
6060- Printf.eprintf "Failed to get mailboxes\n";
6161- exit 1
6262-6363- | Ok mailboxes ->
6464- (* Find the inbox *)
6565- let inbox = List.find_opt (fun m ->
6666- m.Types.role = Some Types.Inbox
6767- ) mailboxes in
6868-6969- match inbox with
7070- | None ->
7171- Printf.eprintf "No inbox found\n";
7272- exit 1
7373-7474- | Some inbox ->
7575- (* Get recent emails *)
7676- let* emails_result = Jmap_mail.get_messages_in_mailbox
7777- conn
7878- ~account_id
7979- ~mailbox_id:inbox.Types.id
8080- ~limit:10
8181- ()
8282- in
8383-8484- match emails_result with
8585- | Error err ->
8686- Printf.eprintf "Failed to get emails\n";
8787- exit 1
8888-8989- | Ok emails ->
9090- (* Display emails *)
9191- List.iter (fun email ->
9292- Printf.printf "%s - %s\n"
9393- (Option.value ~default:"<unknown>"
9494- (Option.map (fun addrs ->
9595- match addrs with
9696- | [] -> "<unknown>"
9797- | addr::_ -> addr.Types.email
9898- ) email.Types.from))
9999- (Option.value ~default:"<no subject>" email.Types.subject)
100100- ) emails;
101101-102102- Lwt.return_unit
2222+opam install .
10323```
1042410525## Features
···14868- [RFC8620: The JSON Meta Application Protocol (JMAP)](https://datatracker.ietf.org/doc/html/rfc8620)
14969- [RFC8621: The JSON Meta Application Protocol (JMAP) for Mail](https://datatracker.ietf.org/doc/html/rfc8621)
15070- [Message Flag and Mailbox Attribute Extension](https://datatracker.ietf.org/doc/html/draft-ietf-mailmaint-messageflag-mailboxattribute-02)
151151-- [Fastmail Developer Documentation](https://www.fastmail.com/dev/)7171+- [Fastmail Developer Documentation](https://www.fastmail.com/dev/)