···
(** Represents an email address with an optional name.
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.2.3> RFC 8621, Section 4.1.2.3 *)
7
-
type email_address = {
8
-
email_addr_name : string option;
9
-
email_addr_email : string;
7
+
module Email_address : sig
10
+
(** Get the display name for the address (if any) *)
11
+
val name : t -> string option
13
+
(** Get the email address *)
14
+
val email : t -> string
16
+
(** Create a new email address *)
(** Represents a group of email addresses.
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.2.4> RFC 8621, Section 4.1.2.4 *)
14
-
type email_address_group = {
15
-
email_group_name : string option;
16
-
email_group_addresses : email_address list;
25
+
module Email_address_group : sig
28
+
(** Get the name of the group (if any) *)
29
+
val name : t -> string option
31
+
(** Get the list of addresses in the group *)
32
+
val addresses : t -> Email_address.t list
34
+
(** Create a new address group *)
37
+
addresses:Email_address.t list ->
(** Represents a header field (name and raw value).
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.3> RFC 8621, Section 4.1.3 *)
21
-
type email_header = {
22
-
header_name : string;
23
-
header_value : string; (* Raw form *)
43
+
module Email_header : sig
46
+
(** Get the header field name *)
47
+
val name : t -> string
49
+
(** Get the raw header field value *)
50
+
val value : t -> string
52
+
(** Create a new header field *)
(** Represents a body part within an Email's MIME structure.
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.4> RFC 8621, Section 4.1.4 *)
28
-
type email_body_part = {
29
-
part_id : string option; (** null only for multipart/* *)
30
-
part_blob_id : id option; (** null only for multipart/* *)
32
-
part_headers : email_header list;
33
-
part_name : string option;
35
-
part_charset : string option;
36
-
part_disposition : string option;
37
-
part_cid : string option;
38
-
part_language : string list option;
39
-
part_location : string option;
40
-
part_sub_parts : email_body_part list option; (** only for multipart/* *)
41
-
part_other_headers : Yojson.Safe.t string_map; (** Requested header:* properties *)
61
+
module Email_body_part : sig
64
+
(** Get the part ID (null only for multipart types) *)
65
+
val id : t -> string option
67
+
(** Get the blob ID (null only for multipart types) *)
68
+
val blob_id : t -> id option
70
+
(** Get the size of the part in bytes *)
71
+
val size : t -> uint
73
+
(** Get the list of headers for this part *)
74
+
val headers : t -> Email_header.t list
76
+
(** Get the filename (if any) *)
77
+
val name : t -> string option
79
+
(** Get the MIME type *)
80
+
val mime_type : t -> string
82
+
(** Get the charset (if any) *)
83
+
val charset : t -> string option
85
+
(** Get the content disposition (if any) *)
86
+
val disposition : t -> string option
88
+
(** Get the content ID (if any) *)
89
+
val cid : t -> string option
91
+
(** Get the list of languages (if any) *)
92
+
val language : t -> string list option
94
+
(** Get the content location (if any) *)
95
+
val location : t -> string option
97
+
(** Get the sub-parts (only for multipart types) *)
98
+
val sub_parts : t -> t list option
100
+
(** Get any other requested headers (header properties) *)
101
+
val other_headers : t -> Yojson.Safe.t string_map
103
+
(** Create a new body part *)
108
+
headers:Email_header.t list ->
110
+
mime_type:string ->
112
+
?disposition:string ->
114
+
?language:string list ->
115
+
?location:string ->
116
+
?sub_parts:t list ->
117
+
?other_headers:Yojson.Safe.t string_map ->
(** Represents the decoded value of a text body part.
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.4> RFC 8621, Section 4.1.4 *)
46
-
type email_body_value = {
47
-
body_value : string;
48
-
is_encoding_problem : bool; (* default: false *)
49
-
is_truncated : bool; (* default: false *)
123
+
module Email_body_value : sig
126
+
(** Get the decoded text content *)
127
+
val value : t -> string
129
+
(** Check if there was an encoding problem *)
130
+
val has_encoding_problem : t -> bool
132
+
(** Check if the content was truncated *)
133
+
val is_truncated : t -> bool
135
+
(** Create a new body value *)
138
+
?encoding_problem:bool ->
143
+
(** Type to represent email message flags/keywords.
144
+
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1.1> RFC 8621, Section 4.1.1 *)
145
+
module Keywords : sig
146
+
(** Represents different types of JMAP keywords *)
148
+
| Draft (** "$draft": The Email is a draft the user is composing *)
149
+
| Seen (** "$seen": The Email has been read *)
150
+
| Flagged (** "$flagged": The Email has been flagged for urgent/special attention *)
151
+
| Answered (** "$answered": The Email has been replied to *)
153
+
(* Common extension keywords from RFC 5788 *)
154
+
| Forwarded (** "$forwarded": The Email has been forwarded *)
155
+
| Phishing (** "$phishing": The Email is likely to be phishing *)
156
+
| Junk (** "$junk": The Email is spam/junk *)
157
+
| NotJunk (** "$notjunk": The Email is explicitly marked as not spam/junk *)
158
+
| Custom of string (** Arbitrary user-defined keyword *)
160
+
(** A set of keywords applied to an email *)
161
+
type t = keyword list
163
+
(** Check if an email has the draft flag *)
164
+
val is_draft : t -> bool
166
+
(** Check if an email has been read *)
167
+
val is_seen : t -> bool
169
+
(** Check if an email has neither been read nor is a draft *)
170
+
val is_unread : t -> bool
172
+
(** Check if an email has been flagged *)
173
+
val is_flagged : t -> bool
175
+
(** Check if an email has been replied to *)
176
+
val is_answered : t -> bool
178
+
(** Check if an email has been forwarded *)
179
+
val is_forwarded : t -> bool
181
+
(** Check if an email is marked as likely phishing *)
182
+
val is_phishing : t -> bool
184
+
(** Check if an email is marked as junk/spam *)
185
+
val is_junk : t -> bool
187
+
(** Check if an email is explicitly marked as not junk/spam *)
188
+
val is_not_junk : t -> bool
190
+
(** Check if a specific custom keyword is set *)
191
+
val has_keyword : t -> string -> bool
193
+
(** Get a list of all custom keywords (excluding system keywords) *)
194
+
val custom_keywords : t -> string list
196
+
(** Add a keyword to the set *)
197
+
val add : t -> keyword -> t
199
+
(** Remove a keyword from the set *)
200
+
val remove : t -> keyword -> t
202
+
(** Create an empty keyword set *)
203
+
val empty : unit -> t
205
+
(** Create a new keyword set with the specified keywords *)
206
+
val of_list : keyword list -> t
208
+
(** Get the string representation of a keyword as used in the JMAP protocol *)
209
+
val to_string : keyword -> string
211
+
(** Parse a string into a keyword *)
212
+
val of_string : string -> keyword
214
+
(** Convert keyword set to string map representation as used in JMAP *)
215
+
val to_map : t -> bool string_map
218
+
(** Represents an Email object.
219
+
@see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.1> RFC 8621, Section 4.1 *)
223
+
(** ID of the email *)
226
+
(** ID of the blob containing the raw message *)
227
+
val blob_id : t -> id
229
+
(** ID of the thread this email belongs to *)
230
+
val thread_id : t -> id
232
+
(** The set of mailbox IDs this email belongs to *)
233
+
val mailbox_ids : t -> bool id_map
235
+
(** The set of keywords/flags for this email *)
236
+
val keywords : t -> Keywords.t
238
+
(** Size of the message in bytes *)
239
+
val size : t -> uint
241
+
(** When the message was received by the server *)
242
+
val received_at : t -> date
244
+
(** Create a new Email object *)
249
+
mailbox_ids:bool id_map ->
250
+
keywords:Keywords.t ->
252
+
received_at:date ->