this repo has no description
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** EmailSubmission type as defined in RFC 8621 Section 7
7
8 @canonical Jmap.Proto.Submission *)
9
10(** {1 EmailSubmission Properties}
11
12 Polymorphic variants for type-safe property selection in EmailSubmission/get requests.
13 These correspond to the properties defined in RFC 8621 Section 7. *)
14
15(** All EmailSubmission properties that can be requested. *)
16type property = [
17 | `Id
18 | `Identity_id
19 | `Email_id
20 | `Thread_id
21 | `Envelope
22 | `Send_at
23 | `Undo_status
24 | `Delivery_status
25 | `Dsn_blob_ids
26 | `Mdn_blob_ids
27]
28
29val property_to_string : [< property ] -> string
30(** Convert a property to its wire name (e.g., [`Identity_id] -> "identityId"). *)
31
32val property_of_string : string -> property option
33(** Parse a property name, case-sensitive. *)
34
35(** {1 Address} *)
36
37(** An address with optional SMTP parameters. *)
38module Address : sig
39 type t = {
40 email : string;
41 (** The email address. *)
42 parameters : (string * string) list option;
43 (** Optional SMTP parameters. *)
44 }
45
46 val email : t -> string
47 val parameters : t -> (string * string) list option
48
49 val jsont : t Jsont.t
50end
51
52(** {1 Envelope} *)
53
54(** SMTP envelope. *)
55module Envelope : sig
56 type t = {
57 mail_from : Address.t;
58 (** MAIL FROM address. *)
59 rcpt_to : Address.t list;
60 (** RCPT TO addresses. *)
61 }
62
63 val mail_from : t -> Address.t
64 val rcpt_to : t -> Address.t list
65
66 val jsont : t Jsont.t
67end
68
69(** {1 Delivery Status} *)
70
71(** Status of delivery to a recipient. *)
72module Delivery_status : sig
73 type delivered = [
74 | `Queued
75 | `Yes
76 | `No
77 | `Unknown
78 ]
79
80 type displayed = [
81 | `Unknown
82 | `Yes
83 ]
84
85 type t = {
86 smtp_reply : string;
87 (** The SMTP reply string. *)
88 delivered : delivered;
89 (** Delivery status. *)
90 displayed : displayed;
91 (** MDN display status. *)
92 }
93
94 val smtp_reply : t -> string
95 val delivered : t -> delivered
96 val displayed : t -> displayed
97
98 val jsont : t Jsont.t
99end
100
101(** {1 Undo Status} *)
102
103type undo_status = [
104 | `Pending
105 | `Final
106 | `Canceled
107]
108
109val undo_status_jsont : undo_status Jsont.t
110
111(** {1 EmailSubmission} *)
112
113type t = {
114 id : Proto_id.t option;
115 (** Server-assigned submission id. *)
116 identity_id : Proto_id.t option;
117 (** The identity used to send. *)
118 email_id : Proto_id.t option;
119 (** The email that was submitted. *)
120 thread_id : Proto_id.t option;
121 (** The thread of the submitted email. *)
122 envelope : Envelope.t option;
123 (** The envelope used, if different from email headers. *)
124 send_at : Ptime.t option;
125 (** When the email was/will be sent. *)
126 undo_status : undo_status option;
127 (** Whether sending can be undone. *)
128 delivery_status : (string * Delivery_status.t) list option;
129 (** Delivery status per recipient. *)
130 dsn_blob_ids : Proto_id.t list option;
131 (** Blob ids of received DSN messages. *)
132 mdn_blob_ids : Proto_id.t list option;
133 (** Blob ids of received MDN messages. *)
134}
135
136val id : t -> Proto_id.t option
137val identity_id : t -> Proto_id.t option
138val email_id : t -> Proto_id.t option
139val thread_id : t -> Proto_id.t option
140val envelope : t -> Envelope.t option
141val send_at : t -> Ptime.t option
142val undo_status : t -> undo_status option
143val delivery_status : t -> (string * Delivery_status.t) list option
144val dsn_blob_ids : t -> Proto_id.t list option
145val mdn_blob_ids : t -> Proto_id.t list option
146
147val jsont : t Jsont.t
148
149(** {1 Filter Conditions} *)
150
151module Filter_condition : sig
152 type t = {
153 identity_ids : Proto_id.t list option;
154 email_ids : Proto_id.t list option;
155 thread_ids : Proto_id.t list option;
156 undo_status : undo_status option;
157 before : Ptime.t option;
158 after : Ptime.t option;
159 }
160
161 val jsont : t Jsont.t
162end