Browse code
1.7
jkf authored on 08/06/2000 14:31:11
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -19,7 +19,7 @@ |
19 | 19 |
;; Commercial Software developed at private expense as specified in |
20 | 20 |
;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable. |
21 | 21 |
;; |
22 |
-;; $Id: imap.cl,v 1.14 2000/06/06 15:53:07 jkf Exp $ |
|
22 |
+;; $Id: imap.cl,v 1.15 2000/06/08 14:31:11 jkf Exp $ |
|
23 | 23 |
|
24 | 24 |
;; Description: |
25 | 25 |
;; |
... | ... |
@@ -75,6 +75,7 @@ |
75 | 75 |
#:make-imap-connection |
76 | 76 |
#:make-pop-connection |
77 | 77 |
#:noop |
78 |
+ #:parse-mail-header |
|
78 | 79 |
#:top-lines ; pop only |
79 | 80 |
#:unique-id ; pop only |
80 | 81 |
|
... | ... |
@@ -94,7 +95,7 @@ |
94 | 95 |
|
95 | 96 |
(provide :imap) |
96 | 97 |
|
97 |
-(defparameter *imap-version-number* '(:major 1 :minor 6)) ; major.minor |
|
98 |
+(defparameter *imap-version-number* '(:major 1 :minor 7)) ; major.minor |
|
98 | 99 |
|
99 | 100 |
;; todo |
100 | 101 |
;; have the list of tags selected done on a per connection basis to |
... | ... |
@@ -1257,12 +1258,12 @@ |
1257 | 1258 |
|
1258 | 1259 |
|
1259 | 1260 |
|
1260 |
-(defun make-envelope-from-text (text) |
|
1261 |
- ;; given at least the headers part of a message return |
|
1262 |
- ;; an envelope structure containing the contents |
|
1263 |
- ;; This is useful for parsing the headers of things returned by |
|
1264 |
- ;; a pop server |
|
1265 |
- ;; |
|
1261 |
+(defun parse-mail-header (text) |
|
1262 |
+ ;; given the partial text of a mail message that includes |
|
1263 |
+ ;; at least the header part, return an assoc list of |
|
1264 |
+ ;; (header . content) items |
|
1265 |
+ ;; Note that the header is string with most likely mixed case names |
|
1266 |
+ ;; as it's conventional to capitalize header names. |
|
1266 | 1267 |
(let ((next 0) |
1267 | 1268 |
(end (length text)) |
1268 | 1269 |
header |
... | ... |
@@ -1356,20 +1357,30 @@ |
1356 | 1357 |
(setf (cdr (car headers)) |
1357 | 1358 |
(concatenate 'string (cdr (car headers)) |
1358 | 1359 |
" " |
1359 |
- value)))))) |
|
1360 |
- |
|
1361 |
- (make-envelope |
|
1362 |
- :date (cdr (assoc "date" headers :test #'equalp)) |
|
1363 |
- :subject (cdr (assoc "subject" headers :test #'equalp)) |
|
1364 |
- :from (cdr (assoc "from" headers :test #'equalp)) |
|
1365 |
- :sender (cdr (assoc "sender" headers :test #'equalp)) |
|
1366 |
- :reply-to (cdr (assoc "reply-to" headers :test #'equalp)) |
|
1367 |
- :to (cdr (assoc "to" headers :test #'equalp)) |
|
1368 |
- :cc (cdr (assoc "cc" headers :test #'equalp)) |
|
1369 |
- :bcc (cdr (assoc "bcc" headers :test #'equalp)) |
|
1370 |
- :in-reply-to (cdr (assoc "in-reply-to" headers :test #'equalp)) |
|
1371 |
- :message-id (cdr (assoc "message-id" headers :test #'equalp)) |
|
1372 |
- )))) |
|
1360 |
+ value))))))) |
|
1361 |
+ headers)) |
|
1362 |
+ |
|
1363 |
+ |
|
1364 |
+(defun make-envelope-from-text (text) |
|
1365 |
+ ;; given at least the headers part of a message return |
|
1366 |
+ ;; an envelope structure containing the contents |
|
1367 |
+ ;; This is useful for parsing the headers of things returned by |
|
1368 |
+ ;; a pop server |
|
1369 |
+ ;; |
|
1370 |
+ (let ((headers (parse-mail-header text))) |
|
1371 |
+ |
|
1372 |
+ (make-envelope |
|
1373 |
+ :date (cdr (assoc "date" headers :test #'equalp)) |
|
1374 |
+ :subject (cdr (assoc "subject" headers :test #'equalp)) |
|
1375 |
+ :from (cdr (assoc "from" headers :test #'equalp)) |
|
1376 |
+ :sender (cdr (assoc "sender" headers :test #'equalp)) |
|
1377 |
+ :reply-to (cdr (assoc "reply-to" headers :test #'equalp)) |
|
1378 |
+ :to (cdr (assoc "to" headers :test #'equalp)) |
|
1379 |
+ :cc (cdr (assoc "cc" headers :test #'equalp)) |
|
1380 |
+ :bcc (cdr (assoc "bcc" headers :test #'equalp)) |
|
1381 |
+ :in-reply-to (cdr (assoc "in-reply-to" headers :test #'equalp)) |
|
1382 |
+ :message-id (cdr (assoc "message-id" headers :test #'equalp)) |
|
1383 |
+ ))) |
|
1373 | 1384 |
|
1374 | 1385 |
|
1375 | 1386 |
|
... | ... |
@@ -689,8 +689,8 @@ user(4): (mailbox-message-count mb) |
689 | 689 |
</div> |
690 | 690 |
|
691 | 691 |
<p align="left"><strong>There are seven messages at the moment. Fetch the |
692 |
-whole 4th message. We could call (fetch-letter mb 4) here instead and then not |
|
693 |
-have to call fetch-field later.</strong></p> |
|
692 |
+whole 4th message. We could call (fetch-letter mb 4) here instead and then not have |
|
693 |
+to call fetch-field later.</strong></p> |
|
694 | 694 |
<div align="left"> |
695 | 695 |
|
696 | 696 |
<pre> |
... | ... |
@@ -1014,6 +1014,18 @@ will contain the current count of messages in the mailbox.</p> |
1014 | 1014 |
|
1015 | 1015 |
<p> </p> |
1016 | 1016 |
|
1017 |
+<p><font face="Courier New"><strong>(parse-mail-header text)</strong></font></p> |
|
1018 |
+ |
|
1019 |
+<p><strong>text</strong> is a string that is the first part of a mail message, including |
|
1020 |
+at least all of the headers lines and the blank line following the headers. This |
|
1021 |
+function parses the header lines and returns an assoc list where each item has the form <strong> |
|
1022 |
+(header . value)</strong>. Both the <strong>header</strong> and <strong>value</strong> |
|
1023 |
+are strings. Note that header names will most likely be mixed case (but this is not |
|
1024 |
+a requirment) so you'll want to use <strong>:test #'equalp</strong> when searching for a |
|
1025 |
+particular header with <strong>assoc</strong>. </p> |
|
1026 |
+ |
|
1027 |
+<p> </p> |
|
1028 |
+ |
|
1017 | 1029 |
<p><font face="Courier New"><strong>(top-lines mb message line-count)</strong></font></p> |
1018 | 1030 |
|
1019 | 1031 |
<p>Return a string that contains all the header lines and the first <strong>line-count</strong> |