1 USING: calendar help.markup help.syntax sequences strings
5 ARTICLE: "imap" "IMAP library"
6 "The " { $vocab-link "imap" } " vocab implements a large part of the IMAP4rev1 client protocol."
8 "IMAP is primarily used for retrieving and managing email and folders on an IMAP server. Note that some IMAP servers, such as " { $snippet "imap.gmail.com" } ", require application-specific passwords."
19 "Constructing an IMAP session:"
20 { $subsections <imap4ssl> }
21 "IMAP folder management:"
32 { $subsections search-mails fetch-mails }
33 "Updating and storing mails:"
34 { $subsections copy-mails append-mail store-mail }
38 "\"imap.gmail.com\" \"email_address@gmail.com\" \"password\" [ list-folders ] with-imap"
41 "USING: imap namespaces ;
42 \\ imap-settings get-global [
43 \"factor\" select-folder drop
44 \"ALL\" \"\" search-mails
45 \"(BODY[HEADER.FIELDS (SUBJECT)])\" fetch-mails
46 ] with-imap-settings 3 head ."
48 \"Subject: [Factor-talk] Wiki Tutorial\"
49 \"Subject: Re: [Factor-talk] font-size in listener\"
50 \"Subject: Re: [Factor-talk] Indentation width and other style guidelines\"
56 { $values { "host" string } { "imap4" "a duplex stream" } }
57 { $description "Connects to an IMAP server using SSL on port 993." } ;
60 { $values { "username" string } { "password" string } { "caps" string } }
61 { $description "Authenticates with the IMAP server." } ;
64 { $values { "caps" string } }
65 { $description "Fetches the advertised extensions of the IMAP server." } ;
68 { $values { "directory" string } { "folders" sequence } }
69 { $description "Lists all folders in " { $snippet "directory" } ". Folders is a sequence of 3-tuples with the attributes, root and name of each folder matched." } ;
72 { $values { "mailbox" string } { "count" "number of mails in the folder" } }
73 { $description "Selects which folder to operate on." } ;
76 { $values { "mailbox" string } }
77 { $description "Creates a new folder." } ;
80 { $values { "mailbox" string } }
81 { $description "Deletes a folder." } ;
84 { $values { "old-name" string } { "new-name" string } }
85 { $description "Renames a folder." } ;
90 { "keys" "a sequence of attributes" }
91 { "assoc" "attribute values" }
93 { $description "Requests a collection of attributes for the specified folder." }
97 \\ imap-settings get-global [
98 \"INBOX\" { \"MESSAGES\" \"UNSEEN\" } status-folder
100 "{ { \"MESSAGES\" 67 } { \"UNSEEN\" 18 } }"
105 { $description "Closes the currently selected folder." } ;
109 { "data-spec" "An IMAP search query" }
110 { "str" "Text to search for" }
111 { "uids" "UID:s of the matching mails" }
113 { $description "Searches the currently selected folder for matching mails. See rfc3501 for the syntax to use for " { $snippet "data-spec" } "." } ;
117 { "uids" "A sequence of UID:s" }
118 { "data-spec" "IMAP Message part specifier" }
119 { "texts" "A sequence of FETCH responses" }
121 { $description "Fetches message parts for the specified mails. See rfc3501 for the format of " { $snippet "data-spec" } "." } ;
125 { "uids" "A sequence of UID:s" }
128 { $description "Copies a set of mails to the specified folder." } ;
134 { "date-time" timestamp }
136 { "uid/f" "UID of the mail if the server supports UIDPLUS, f otherwise" }
138 { $description "Appends a mail to the specified folder." } ;
142 { "uids" "A sequence of UID:s" }
143 { "command" "An IMAP store command" }
144 { "flags" "Flags to set or remove" }
145 { "mail-flags" "Flags of mails after update" }
147 { $description "Updates the attributes of a set of mails." } ;
150 { $var-description "A tuple for holding the host, email, and password for an IMAP account. Setting this information as a global variable in your .factor-rc or .factor-boot-rc is recommended." }
152 "Run the next example and click the link to edit your boot rc:"
155 "USING: imap tools.scaffold ; "
156 "scaffold-factor-boot-rc"
159 "Add the following settings to your bootstrap rc file:"
161 "USING: imap namespaces ;"
162 "\"imap.gmail.com\" \"foo@gmail.com\" \"password\" <imap-settings> \\ imap-settings set-global"
165 "Run your boot rc again:"
167 "USING: command-line ;"
172 { $see-also with-imap-settings } ;
176 { "host" string } { "email" string } { "password" string } { "quot" quotation }
178 { $description "Logs into the IMAP server with the provided settings. The quotation should contain code to execute once authentication has aloready occurred." } ;
180 HELP: with-imap-settings
182 { "imap-settings" imap-settings } { "quot" quotation }
184 { $description "Logs into the IMAP server with the provided settings. The quotation should contain code to execute once authentication has aloready occurred." } ;
186 { with-imap with-imap-settings } related-words