Clonsigna: easy IMAP rev4 client library
version 0.1.1
Clonsigna is a Common Lisp library that allows interaction with IMAP4rev1 servers.
Clonsigna is very easy to use and follows the rfc3501 and rfc5256 specifications.
It allows both IMAP and IMAP over SSL communications.
The most of the commands output has it's own message parser that maps a server reply to a Common Lisp element (usually plists and classes).
Mail messages are completely handled and decoded by clonsigna parsers so that you'll have a mail message "ready to use".
Dependencies: iolib (git), cl-base64, cl-ppcre, split-sequence, alexandria, cl+ssl (cvs)
The following is an example, thought not exaustive, of how much Clonsigna can be easy to use:
CL-USER> (use-package :clonsigna)
T
CL-USER> (defvar *s* (make-imap :host "127.0.0.1"))
*S*
CL-USER> (cmd-connect *s*)
(:AUTH ("PLAIN") :STARTTLS (T) :LIST-STATUS (T) :CONTEXT ("SEARCH") :WITHIN (T)
:SEARCHRES (T) :ESORT (T) :ESEARCH (T) :QRESYNC (T) :CONDSTORE (T) :I18NLEVEL
("1") :LIST-EXTENDED (T) :UIDPLUS (T) :NAMESPACE (T) :CHILDREN (T) :IDLE (T)
:UNSELECT (T) :MULTIAPPEND (T) :THREAD ("REFERENCES" "REFS") :SORT
(T "DISPLAY") :ENABLE (T) :ID (T) :LOGIN-REFERRALS (T) :SASL-IR (T) :LITERAL+
(T) :IMAP4REV1 (T))
CL-USER> (cmd-login *s* "kiuma" "secret")
NIL
"OK"
"[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in"
CL-USER> (cmd-select *s* "inbox")
("* FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft $MDNSent)"
"* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft $MDNSent \\*)] Flags permitted."
"* 1328 EXISTS" "* 29 RECENT" "* OK [UNSEEN 17] First unseen."
"* OK [UIDVALIDITY 1276152973] UIDs valid"
"* OK [UIDNEXT 1363] Predicted next UID" "* OK [HIGHESTMODSEQ 98] Highest"
)
"OK"
"[READ-WRITE] Select completed."
CL-USER> (parse-thread (cmd-thread *s*))
(((1324) (1325) (1316) (1317) (1327) (1313) (1314) (1318) (1319) (1326) (1312)
  (1323) (1322) (1315) (1321) (1320) (1328) (1329) (1330) (1331) (1332) (1333)
  (1334) (1335) (1336) (1337) (1338) (1339) (1340) (1341) (1342) (1343) (1344)
  (1345) (1346) (1347) (1348) (1349) (1350) (1351) (1352) (1353) (1354) (1355)
  (1356) (1357) (1358) (1359) (1360) (1361) (1362))
((1258) (1311))
...
)
CL-USER> (parse-fetch-fields (cmd-fetch-fields *s* 1258))
((:ID 1258 :UID 1258 :FLAGS (SEEN) :BODYSTRUCTURE
  ("text" "plain" ("charset" "ISO-8859-15") NIL NIL "7bit" 20 1 NIL NIL NIL
   NIL)
  :HEADERS
  (:MESSAGE-ID "<4C108DD1.4010509@localhost>" :DATE
   "Thu, 10 Jun 2010 09:01:37 +0200" :FROM
   "kiuma :TO "kiuma@localhost.localdomain"
   :SUBJECT "Hello")))
  
   (defvar *bs* (make-bodystructure
                       (parse-bodystructure
                        (getf (first (parse-fetch-fields (cmd-fetch-fields *s* 1258)))
                              :bodystructure))))
      
CL-USER> (structure-element-section (first (bodystructure-body-list *bs*)))
(1)
CL-USER> (parse-fetch-body (first (cmd-fetch-body *s* 1258 :section '(1)))
                           :charset "ISO-8859-15"
                           :encoding "7bit")
"
Test message

"