home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / imail / imap-response.txt < prev    next >
Text File  |  2000-06-01  |  10KB  |  405 lines

  1. $Id: imap-response.txt,v 1.6 2000/06/01 04:56:42 cph Exp $
  2.  
  3. Notes on IMAP server responses
  4.  
  5. + <resp-text>            ;continuation response
  6. + <base64>            ;continuation response
  7.  
  8. * OK <resp-text>        ;status condition
  9. * NO <resp-text>        ;status condition
  10. * BAD <resp-text>        ;status condition
  11. * BYE <resp-text>        ;fatal if not response to LOGOUT
  12.  
  13. * FLAGS (#<flag>)
  14. * LIST (#<flag>) <delim> <mailbox>
  15. * LSUB (#<flag>) <delim> <mailbox>
  16. * SEARCH <nz-number> ...
  17. * STATUS <mailbox> (<status-attribute> <number> ...)
  18. * <number> EXISTS
  19. * <number> RECENT
  20. * <nz-number> EXPUNGE
  21. * <nz-number> FETCH (<message-attribute> <message-attribute> ...)
  22. * CAPABILITY <capability> ... IMAP4rev1 <capability> ...
  23.  
  24. <tag> OK <resp-text>        ;end of response to tagged command
  25. <tag> NO <resp-text>        ;end of response to tagged command
  26. <tag> BAD <resp-text>        ;end of response to tagged command
  27.  
  28.  
  29. <resp-text>
  30.     = <text>
  31.     = <text-mime2>
  32.     = [<resp-text-code>] <text>
  33.     = [<resp-text-code>] <text-mime2>
  34.  
  35. <resp-text-code>
  36.     = ALERT
  37.     = PARSE
  38.     = PERMANENTFLAGS (#<pflag>)
  39.     = READ-ONLY
  40.     = READ-WRITE
  41.     = TRYCREATE
  42.     = UIDVALIDITY <nz-number>
  43.     = UNSEEN <nz-number>
  44.     = <atom>
  45.     = <atom> <text-except-close-bracket>
  46.  
  47. <pflag>
  48.     = <flag>
  49.     = \*
  50.  
  51. <flag>
  52.     = \<atom>
  53.     = <atom>
  54.  
  55. <delim>
  56.     = "<quoted-char>"
  57.     = NIL
  58.  
  59. <mailbox>
  60.     = INBOX
  61.     = <astring>
  62.  
  63. <status-attribute>
  64.     = MESSAGES
  65.     = RECENT
  66.     = UIDNEXT
  67.     = UIDVALIDITY
  68.     = UNSEEN
  69.  
  70. <message-attribute>
  71.     = ENVELOPE <envelope>
  72.     = FLAGS (<flag> ...)
  73.     = INTERNALDATE <date-time>
  74.     = RFC822 <nstring>
  75.     = RFC822.HEADER <nstring>
  76.     = RFC822.TEXT <nstring>
  77.     = RFC822.SIZE <number>
  78.     = BODY <body>
  79.     = BODYSTRUCTURE <body>
  80.     = BODY[<section>] <nstring>
  81.     = BODY[<section>]<<number>> <nstring>
  82.     = UID <nz-number>
  83.  
  84. <envelope>
  85.     = (<nstring>        ;date
  86.        <nstring>        ;subject
  87.        <address-list>    ;from
  88.        <address-list>    ;sender
  89.        <address-list>    ;reply-to
  90.        <address-list>    ;to
  91.        <address-list>    ;cc
  92.        <address-list>    ;bcc
  93.        <nstring>        ;in-reply-to
  94.        <nstring>        ;message-id
  95.        )
  96.  
  97. <address-list>
  98.     = (<address> <address> ...)
  99.     = NIL
  100.  
  101. <address>
  102.     = (<nstring>        ;name
  103.        <nstring>        ;route-addr
  104.        <nstring>        ;local-part
  105.        <nstring>        ;domain-name
  106.       )
  107.  
  108. <date-time> = "<date-day-fixed>-<month>-<4digit> <time> <zone>"
  109. <date-day-fixed>
  110.     =  <digit>
  111.     = <2digit>
  112. <month>
  113.     = Jan
  114.     = Feb
  115.     = Mar
  116.     = Apr
  117.     = May
  118.     = Jun
  119.     = Jul
  120.     = Aug
  121.     = Sep
  122.     = Oct
  123.     = Nov
  124.     = Dec
  125.  
  126. <time> = <2digit>:<2digit>:<2digit>
  127. <zone> = <sign><4digit>
  128.  
  129. <body>
  130.     = (<body-type-1part>)
  131.     = (<body-type-mpart>)
  132.  
  133. <body-type-mpart>
  134.     = <body><body> ... <string>
  135.     = <body><body> ... <string> <body-ext-mpart>
  136. <body-ext-mpart>
  137.     = <body-field-param>
  138.     = <body-field-param> <body-field-dsp> <body-field-lang> <body-extension> ...
  139.  
  140. <body-type-1part>
  141.     = <body-type-basic>
  142.     = <body-type-basic> <body-ext-1part>
  143.     = <body-type-msg>
  144.     = <body-type-msg> <body-ext-1part>
  145.     = <body-type-text>
  146.     = <body-type-text> <body-ext-1part>
  147. <body-type-basic> = <string> <string> <body-fields>
  148. <body-type-msg> = "MESSAGE" "RFC822" <body-fields> <envelope> <body> <number>
  149. <body-type-text> = "TEXT" <string> <body-fields> <number>
  150. <body-ext-1part>
  151.     = <nstring>
  152.     = <nstring> <body-field-dsp>
  153.     = <nstring> <body-field-dsp> <body-field-lang> <body-extension> ...
  154. <body-field-dsp>
  155.     = (<string> <body-field-param>)
  156.     = NIL
  157. <body-field-lang>
  158.     = <nstring>
  159.     = (<astring> <astring> ...)
  160. <body-extension>
  161.     = <nstring>
  162.     = <number>
  163.     = (<body-extension> <body-extension> ...)
  164. <body-fields> = <body-field-param> <nstring> <nstring> <string> <number>
  165. <body-field-param>
  166.     = (<string> <string> ...)        ;even number of <string>s
  167.     = NIL
  168.  
  169.  
  170. <section>
  171.     = [<section-text>]
  172.     = [<nz-number>.<nz-number>. ... <section-text>]
  173.     = [<nz-number>.<nz-number>. ... MIME]
  174. <section-text>
  175.     = HEADER
  176.     = HEADER.FIELDS <header-list>
  177.     = HEADER.FIELDS.NOT <header-list>
  178.     = TEXT
  179. <header-list> = (<astring> <astring> ...)
  180.  
  181.  
  182.  
  183. <capability>
  184.     = AUTH=<atom>
  185.     = <atom>
  186.  
  187.  
  188.  
  189. <astring>
  190.     = <atom>
  191.     = <string>
  192.  
  193. <nstring>
  194.     = NIL
  195.     = <string>
  196.  
  197. <string>
  198.     = <quoted-string>
  199.     = <literal>
  200.  
  201.  
  202. ;;; Base syntax types:
  203.  
  204. <quoted-string> = "<quoted-char>..."
  205. <literal> = {<number>}\r\n<byte>...
  206. <atom> = <atom-char><atom-char>...
  207. <text> = <text-char><text-char>...
  208. <text-mime2> = =?<charset>?<encoding>?<encoded-text>?=
  209. <base64> = ;base64 characters
  210. <number> = <digit><digit>...
  211. <nz-number> = <number>        ;not 0
  212.  
  213. <server-response>
  214.     = (BAD <string-or-false> <response-text>)
  215.     | (BYE <response-text>)
  216.     | (CAPABILITY <symbol>*)
  217.     | (CONTINUE <response-text>)
  218.     | (EXISTS <nonnegative-exact-integer>)
  219.     | (EXPUNGE <positive-exact-integer>)
  220.     | (FETCH <positive-exact-integer> <fetch-response>+)
  221.     | (FLAGS <symbol>*)
  222.     | (LIST <string-or-false> <string> <symbol>*)
  223.     | (LSUB <string-or-false> <string> <symbol>*)
  224.     | (NO <string-or-false> <response-text>)
  225.     | (OK <string-or-false> <response-text>)
  226.     | (PREAUTH <response-text>)
  227.     | (RECENT <nonnegative-exact-integer>)
  228.     | (SEARCH <positive-exact-integer>+)
  229.     | (STATUS <string> (<symbol> . <positive-exact-integer>)*)
  230.  
  231. <response-text>
  232.     = <response-text-code> <string>
  233.     | <response-text-code>
  234.       (<string>            ;charset
  235.        <string>            ;encoding
  236.        <string>)            ;encoded text
  237.  
  238. <response-text-code>
  239.     = #F
  240.     | (ALERT)
  241.     | (BADCHARSET <string>*)
  242.     | (NEWNAME <string> <string>)    ;old-name new-name
  243.     | (PARSE)
  244.     | (READ-ONLY)
  245.     | (READ-WRITE)
  246.     | (TRYCREATE)
  247.     | (UIDNEXT <positive-exact-integer>)
  248.     | (UIDVALIDITY <positive-exact-integer>)
  249.     | (UNSEEN <positive-exact-integer>)
  250.     | (PERMANENTFLAGS <symbol>*)
  251.     | (<symbol>)
  252.     | (<symbol> <string>)
  253.  
  254. <fetch-response>
  255.     = (ENVELOPE <envelope>)
  256.     | (FLAGS (<symbol>*))
  257.     | (INTERNALDATE <nonnegative-exact-integer>)
  258.     | (RFC822 <string-or-false>)
  259.     | (RFC822.HEADER <string-or-false>)
  260.     | (RFC822.TEXT <string-or-false>)
  261.     | (RFC822.SIZE <nonnegative-exact-integer>)
  262.     | (BODY <section> <number-or-false> <string-or-false>)
  263.     | (BODY <body>)
  264.     | (BODYSTRUCTURE <body>)
  265.     | (UID <positive-exact-integer>)
  266.  
  267. <section>
  268.     = (<positive-exact-integer>+)
  269.     | (<positive-exact-integer>+ MIME)
  270.     | (<positive-exact-integer>* HEADER)
  271.     | (<positive-exact-integer>* TEXT)
  272.     | (<positive-exact-integer>* HEADER.FIELDS <header>+)
  273.     | (<positive-exact-integer>* HEADER.FIELDS.NOT <header>+)
  274.  
  275. <envelope>
  276.     = (<string-or-false>        ;date
  277.        <string-or-false>        ;subject
  278.        <addr-list>            ;from
  279.        <addr-list>            ;sender
  280.        <addr-list>            ;reply-to
  281.        <addr-list>            ;to
  282.        <addr-list>            ;cc
  283.        <addr-list>            ;bcc
  284.        <string-or-false>        ;in-reply-to
  285.        <string-or-false>        ;message-id
  286.        )
  287. <addr-list>
  288.     = (<address>+)
  289.     | #f
  290.  
  291. <address>
  292.     = (<string-or-false>        ;personal name
  293.        <string-or-false>        ;source route
  294.        <string>            ;mailbox name
  295.        <string>            ;host name
  296.        )
  297.     | (#f #f <string> #f)        ;start of group
  298.     | (#f #f #f #f)            ;end of group
  299.  
  300. <body>                    ;too complicated to describe
  301.  
  302. <string-or-false>
  303.     = <string>
  304.     | #F
  305.  
  306. <number-or-false
  307.     = <nonnegative-exact-integer>
  308.     | #F
  309.  
  310. Notes about handling responses:
  311.  
  312. * Check CAPABILITY for IMAP4rev1 and refuse to deal if not present.
  313.  
  314. * MUST record the following: FLAGS, EXISTS, RECENT, EXPUNGE.  However,
  315.   we won't use RECENT, so ignore it.
  316.  
  317. * Setup sequence:
  318.  
  319.   1. Select mailbox.  Record FLAGS, PERMANENTFLAGS, EXISTS, and
  320.      UIDVALIDITY.
  321.  
  322.   2. For each message in mailbox, do FETCH ALL and record the results.
  323.  
  324.   3. Build summary buffer based on this information.
  325.  
  326. * When user selects a message, do FETCH RFC822 and present it in the
  327.   buffer.
  328.  
  329. * When EXISTS is received and doesn't match the current length, or
  330.   When UIDVALIDITY received and doesn't match the current value,
  331.   rebuild our model of the mailbox.  Redo #1, #2, #3.  Match up the
  332.   UID numbers with the stored message objects and adjust as needed.
  333.  
  334. * When FLAGS or PERMANENTFLAGS received, record them.
  335.  
  336. * When EXPUNGE received, delete the corresponding message object.
  337.  
  338. * Probably should do something with READ-ONLY and READ-WRITE; ignore
  339.   them for now.
  340.  
  341. (define conn (open-imap-socket "localhost" "cph-imap" "foobar"))
  342. * OK zurich Cyrus IMAP4 v1.5.19 server ready
  343. A0000 LOGIN cph-imap foobar
  344. (ok "A0000" () "User logged in")
  345. ;Value: conn
  346.  
  347. (imap-command conn "select" "inbox")
  348. A0001 select inbox
  349. (flags \answered \flagged \draft \deleted \seen)
  350. (ok () (permanentflags \answered \flagged \draft \deleted \seen \*) "")
  351. (exists 4)
  352. (recent 0)
  353. (ok () (uidvalidity 947120402) "")
  354. (ok "A0001" read-write "Completed")
  355. ;Unspecified return value
  356.  
  357. (imap-command conn "fetch" "1" "envelope")
  358. *** output flushed ***
  359. ;Unspecified return value
  360.  
  361. (imap-command conn "fetch" "1" "(envelope uid)")
  362. *** output flushed ***
  363. ;Unspecified return value
  364.  
  365. (imap-command conn "fetch" "1" "(envelope uid rfc822.size)")
  366. A0004 fetch 1 (envelope uid rfc822.size)
  367. (fetch
  368.  (uid 1)
  369.  (rfc822.size 639)
  370.  (envelope "Wed, 05 Jan 2000 20:01:10 -0500"
  371.            "test 1"
  372.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  373.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  374.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  375.            ((() () "cph-imap" "zurich.ai.mit.edu"))
  376.            ()
  377.            ()
  378.            ()
  379.            "<E1261Ic-0001M8-00@flenser.ai.mit.edu>"))
  380. (ok "A0004" () "Completed")
  381. ;Unspecified return value
  382.  
  383. (imap-command conn "fetch" "1" "rfc822.header")
  384. *** output flushed ***
  385. ;Unspecified return value
  386.  
  387. (imap-command conn "fetch" "1" "all")
  388. A0006 fetch 1 all
  389. (fetch
  390.  (flags \answered \seen)
  391.  (internaldate " 5-Jan-2000 20:01:10 -0500")
  392.  (rfc822.size 639)
  393.  (envelope "Wed, 05 Jan 2000 20:01:10 -0500"
  394.            "test 1"
  395.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  396.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  397.            (("Chris Hanson" () "cph" "zurich.ai.mit.edu"))
  398.            ((() () "cph-imap" "zurich.ai.mit.edu"))
  399.            ()
  400.            ()
  401.            ()
  402.            "<E1261Ic-0001M8-00@flenser.ai.mit.edu>"))
  403. (ok "A0006" () "Completed")
  404. ;Unspecified return value
  405.