mm-util.el (mm-ucs-to-char): Use eval-and-compile.
[gnus] / lisp / pop3.el
1 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;;   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5
6 ;; Author: Richard L. Pieri <ratinox@peorth.gweep.net>
7 ;; Maintainer: FSF
8 ;; Keywords: mail
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; Most of the standard Post Office Protocol version 3 (RFC 1460) commands
28 ;; are implemented.  The LIST command has not been implemented due to lack
29 ;; of actual usefulness.
30 ;; The optional POP3 command TOP has not been implemented.
31
32 ;; This program was inspired by Kyle E. Jones's vm-pop program.
33
34 ;;; Code:
35
36 (eval-when-compile (require 'cl))
37 (require 'mail-utils)
38 (defvar parse-time-months)
39
40 (defgroup pop3 nil
41   "Post Office Protocol."
42   :group 'mail
43   :group 'mail-source)
44
45 (defcustom pop3-maildrop (or (user-login-name)
46                              (getenv "LOGNAME")
47                              (getenv "USER"))
48   "*POP3 maildrop."
49   :version "22.1" ;; Oort Gnus
50   :type 'string
51   :group 'pop3)
52
53 (defcustom pop3-mailhost (or (getenv "MAILHOST") ;; nil -> mismatch
54                              "pop3")
55   "*POP3 mailhost."
56   :version "22.1" ;; Oort Gnus
57   :type 'string
58   :group 'pop3)
59
60 (defcustom pop3-port 110
61   "*POP3 port."
62   :version "22.1" ;; Oort Gnus
63   :type 'number
64   :group 'pop3)
65
66 (defcustom pop3-password-required t
67   "*Non-nil if a password is required when connecting to POP server."
68   :version "22.1" ;; Oort Gnus
69   :type 'boolean
70   :group 'pop3)
71
72 ;; Should this be customizable?
73 (defvar pop3-password nil
74   "*Password to use when connecting to POP server.")
75
76 (defcustom pop3-authentication-scheme 'pass
77   "*POP3 authentication scheme.
78 Defaults to `pass', for the standard USER/PASS authentication.  The other
79 valid value is 'apop'."
80   :type '(choice (const :tag "Normal user/password" pass)
81                  (const :tag "APOP" apop))
82   :version "22.1" ;; Oort Gnus
83   :group 'pop3)
84
85 (defcustom pop3-stream-length 100
86   "How many messages should be requested at one time.
87 The lower the number, the more latency-sensitive the fetching
88 will be.  If your pop3 server doesn't support streaming at all,
89 set this to 1."
90   :type 'number
91   :version "24.1"
92   :group 'pop3)
93
94 (defcustom pop3-leave-mail-on-server nil
95   "*Non-nil if the mail is to be left on the POP server after fetching.
96
97 If `pop3-leave-mail-on-server' is non-nil the mail is to be left
98 on the POP server after fetching.  Note that POP servers maintain
99 no state information between sessions, so what the client
100 believes is there and what is actually there may not match up.
101 If they do not, then you may get duplicate mails or the whole
102 thing can fall apart and leave you with a corrupt mailbox."
103   ;; We can't use the UILD support from XEmacs mail-lib or cvs.m17n.org:
104   ;; http://thread.gmane.org/v9lld8fml4.fsf@marauder.physik.uni-ulm.de
105   ;; http://thread.gmane.org/b9yy8hzy9ej.fsf@jpl.org
106   ;; Any volunteer to re-implement this?
107   :version "22.1" ;; Oort Gnus
108   :type 'boolean
109   :group 'pop3)
110
111 (defvar pop3-timestamp nil
112   "Timestamp returned when initially connected to the POP server.
113 Used for APOP authentication.")
114
115 (defvar pop3-read-point nil)
116 (defvar pop3-debug nil)
117
118 ;; Borrowed from nnheader-accept-process-output in nnheader.el.  See the
119 ;; comments there for explanations about the values.
120
121 (eval-and-compile
122   (if (and (fboundp 'nnheader-accept-process-output)
123            (boundp 'nnheader-read-timeout))
124       (defalias 'pop3-accept-process-output 'nnheader-accept-process-output)
125     ;; Borrowed from `nnheader.el':
126     (defvar pop3-read-timeout
127       (if (string-match "windows-nt\\|os/2\\|cygwin"
128                         (symbol-name system-type))
129           1.0
130         0.01)
131       "How long pop3 should wait between checking for the end of output.
132 Shorter values mean quicker response, but are more CPU intensive.")
133     (defun pop3-accept-process-output (process)
134       (accept-process-output
135        process
136        (truncate pop3-read-timeout)
137        (truncate (* (- pop3-read-timeout
138                        (truncate pop3-read-timeout))
139                     1000))))))
140
141 ;;;###autoload
142 (defun pop3-movemail (file)
143   "Transfer contents of a maildrop to the specified FILE.
144 Use streaming commands."
145   (let* ((process (pop3-open-server pop3-mailhost pop3-port))
146          message-count message-total-size)
147     (pop3-logon process)
148     (with-current-buffer (process-buffer process)
149       (let ((size (pop3-stat process)))
150         (setq message-count (car size)
151               message-total-size (cadr size)))
152       (when (> message-count 0)
153         (pop3-send-streaming-command
154          process "RETR" message-count message-total-size)
155         (pop3-write-to-file file)
156         (unless pop3-leave-mail-on-server
157           (pop3-send-streaming-command
158            process "DELE" message-count nil))))
159     (pop3-quit process)
160     t))
161
162 (defun pop3-send-streaming-command (process command count total-size)
163   (erase-buffer)
164   (let ((i 1))
165     (while (>= count i)
166       (process-send-string process (format "%s %d\r\n" command i))
167       ;; Only do 100 messages at a time to avoid pipe stalls.
168       (when (zerop (% i pop3-stream-length))
169         (pop3-wait-for-messages process i total-size))
170       (incf i)))
171   (pop3-wait-for-messages process count total-size))
172
173 (defun pop3-wait-for-messages (process count total-size)
174   (while (< (pop3-number-of-responses total-size) count)
175     (when total-size
176       (message "pop3 retrieved %dKB (%d%%)"
177                (truncate (/ (buffer-size) 1000))
178                (truncate (* (/ (* (buffer-size) 1.0)
179                                total-size) 100))))
180     (pop3-accept-process-output process)))
181
182 (defun pop3-write-to-file (file)
183   (let ((pop-buffer (current-buffer))
184         (start (point-min))
185         beg end
186         temp-buffer)
187     (with-temp-buffer
188       (setq temp-buffer (current-buffer))
189       (with-current-buffer pop-buffer
190         (goto-char (point-min))
191         (while (re-search-forward "^\\+OK" nil t)
192           (forward-line 1)
193           (setq beg (point))
194           (when (re-search-forward "^\\.\r?\n" nil t)
195             (setq start (point))
196             (forward-line -1)
197             (setq end (point)))
198           (with-current-buffer temp-buffer
199             (goto-char (point-max))
200             (let ((hstart (point)))
201               (insert-buffer-substring pop-buffer beg end)
202               (pop3-clean-region hstart (point))
203               (goto-char (point-max))
204               (pop3-munge-message-separator hstart (point))
205               (goto-char (point-max))))))
206       (let ((coding-system-for-write 'binary))
207         (goto-char (point-min))
208         ;; Check whether something inserted a newline at the start and
209         ;; delete it.
210         (when (eolp)
211           (delete-char 1))
212         (write-region (point-min) (point-max) file nil 'nomesg)))))
213
214 (defun pop3-number-of-responses (endp)
215   (let ((responses 0))
216     (save-excursion
217       (goto-char (point-min))
218       (while (or (and (re-search-forward "^\\+OK" nil t)
219                       (or (not endp)
220                           (re-search-forward "^\\.\r?\n" nil t)))
221                  (re-search-forward "^-ERR " nil t))
222         (incf responses)))
223     responses))
224
225 (defun pop3-logon (process)
226   (let ((pop3-password pop3-password))
227     ;; for debugging only
228     (if pop3-debug (switch-to-buffer (process-buffer process)))
229     ;; query for password
230     (if (and pop3-password-required (not pop3-password))
231         (setq pop3-password
232               (read-passwd (format "Password for %s: " pop3-maildrop))))
233     (cond ((equal 'apop pop3-authentication-scheme)
234            (pop3-apop process pop3-maildrop))
235           ((equal 'pass pop3-authentication-scheme)
236            (pop3-user process pop3-maildrop)
237            (pop3-pass process))
238           (t (error "Invalid POP3 authentication scheme")))))
239
240 (defun pop3-get-message-count ()
241   "Return the number of messages in the maildrop."
242   (let* ((process (pop3-open-server pop3-mailhost pop3-port))
243          message-count
244          (pop3-password pop3-password))
245     ;; for debugging only
246     (if pop3-debug (switch-to-buffer (process-buffer process)))
247     ;; query for password
248     (if (and pop3-password-required (not pop3-password))
249         (setq pop3-password
250               (read-passwd (format "Password for %s: " pop3-maildrop))))
251     (cond ((equal 'apop pop3-authentication-scheme)
252            (pop3-apop process pop3-maildrop))
253           ((equal 'pass pop3-authentication-scheme)
254            (pop3-user process pop3-maildrop)
255            (pop3-pass process))
256           (t (error "Invalid POP3 authentication scheme")))
257     (setq message-count (car (pop3-stat process)))
258     (pop3-quit process)
259     message-count))
260
261 (autoload 'open-tls-stream "tls")
262 (autoload 'starttls-open-stream "starttls")
263 (autoload 'starttls-negotiate "starttls") ; avoid warning
264
265 (defcustom pop3-stream-type nil
266   "*Transport security type for POP3 connexions.
267 This may be either nil (plain connexion), `ssl' (use an
268 SSL/TSL-secured stream) or `starttls' (use the starttls mechanism
269 to turn on TLS security after opening the stream).  However, if
270 this is nil, `ssl' is assumed for connexions to port
271 995 (pop3s)."
272   :version "23.1" ;; No Gnus
273   :group 'pop3
274   :type '(choice (const :tag "Plain" nil)
275                  (const :tag "SSL/TLS" ssl)
276                  (const starttls)))
277
278 (eval-and-compile
279   (if (fboundp 'set-process-query-on-exit-flag)
280       (defalias 'pop3-set-process-query-on-exit-flag
281         'set-process-query-on-exit-flag)
282     (defalias 'pop3-set-process-query-on-exit-flag
283       'process-kill-without-query)))
284
285 (defun pop3-open-server (mailhost port)
286   "Open TCP connection to MAILHOST on PORT.
287 Returns the process associated with the connection."
288   (let ((coding-system-for-read 'binary)
289         (coding-system-for-write 'binary)
290         process)
291     (with-current-buffer
292         (get-buffer-create (concat " trace of POP session to "
293                                    mailhost))
294       (erase-buffer)
295       (setq pop3-read-point (point-min))
296       (setq process
297             (cond
298              ((or (eq pop3-stream-type 'ssl)
299                   (and (not pop3-stream-type) (member port '(995 "pop3s"))))
300               ;; gnutls-cli, openssl don't accept service names
301               (if (or (equal port "pop3s")
302                       (null port))
303                   (setq port 995))
304               (let ((process (open-tls-stream "POP" (current-buffer)
305                                               mailhost port)))
306                 (when process
307                   ;; There's a load of info printed that needs deleting.
308                   (let ((again 't))
309                     ;; repeat until
310                     ;; - either we received the +OK line
311                     ;; - or accept-process-output timed out without getting
312                     ;;   anything
313                     (while (and again
314                                 (setq again (memq (process-status process)
315                                                   '(open run))))
316                       (setq again (pop3-accept-process-output process))
317                       (goto-char (point-max))
318                       (forward-line -1)
319                       (cond ((looking-at "\\+OK")
320                              (setq again nil)
321                              (delete-region (point-min) (point)))
322                             ((not again)
323                              (pop3-quit process)
324                              (error "POP SSL connexion failed")))))
325                   process)))
326              ((eq pop3-stream-type 'starttls)
327               ;; gnutls-cli, openssl don't accept service names
328               (if (equal port "pop3")
329                   (setq port 110))
330               ;; Delay STLS until server greeting is read (Bug#7438).
331               (starttls-open-stream "POP" (current-buffer)
332                                     mailhost (or port 110)))
333              (t
334               (open-network-stream "POP" (current-buffer) mailhost port))))
335       (let ((response (pop3-read-response process t)))
336         (setq pop3-timestamp
337               (substring response (or (string-match "<" response) 0)
338                          (+ 1 (or (string-match ">" response) -1)))))
339       (when (eq pop3-stream-type 'starttls)
340         (pop3-send-command process "STLS")
341         (let ((response (pop3-read-response process t)))
342           (if (and response (string-match "+OK" response))
343               (starttls-negotiate process)
344             (pop3-quit process)
345             (error "POP server doesn't support starttls"))))
346       (pop3-set-process-query-on-exit-flag process nil)
347       process)))
348
349 ;; Support functions
350
351 (defun pop3-send-command (process command)
352   (set-buffer (process-buffer process))
353   (goto-char (point-max))
354   ;; (if (= (aref command 0) ?P)
355   ;;     (insert "PASS <omitted>\r\n")
356   ;;   (insert command "\r\n"))
357   (setq pop3-read-point (point))
358   (goto-char (point-max))
359   (process-send-string process (concat command "\r\n")))
360
361 (defun pop3-read-response (process &optional return)
362   "Read the response from the server.
363 Return the response string if optional second argument is non-nil."
364   (let ((case-fold-search nil)
365         match-end)
366     (with-current-buffer (process-buffer process)
367       (goto-char pop3-read-point)
368       (while (and (memq (process-status process) '(open run))
369                   (not (search-forward "\r\n" nil t)))
370         (pop3-accept-process-output process)
371         (goto-char pop3-read-point))
372       (setq match-end (point))
373       (goto-char pop3-read-point)
374       (if (looking-at "-ERR")
375           (error "%s" (buffer-substring (point) (- match-end 2)))
376         (if (not (looking-at "+OK"))
377             (progn (setq pop3-read-point match-end) nil)
378           (setq pop3-read-point match-end)
379           (if return
380               (buffer-substring (point) match-end)
381             t)
382           )))))
383
384 (defun pop3-clean-region (start end)
385   (setq end (set-marker (make-marker) end))
386   (save-excursion
387     (goto-char start)
388     (while (and (< (point) end) (search-forward "\r\n" end t))
389       (replace-match "\n" t t))
390     (goto-char start)
391     (while (and (< (point) end) (re-search-forward "^\\." end t))
392       (replace-match "" t t)
393       (forward-char)))
394   (set-marker end nil))
395
396 ;; Copied from message-make-date.
397 (defun pop3-make-date (&optional now)
398   "Make a valid date header.
399 If NOW, use that time instead."
400   (require 'parse-time)
401   (let* ((now (or now (current-time)))
402          (zone (nth 8 (decode-time now)))
403          (sign "+"))
404     (when (< zone 0)
405       (setq sign "-")
406       (setq zone (- zone)))
407     (concat
408      (format-time-string "%d" now)
409      ;; The month name of the %b spec is locale-specific.  Pfff.
410      (format " %s "
411              (capitalize (car (rassoc (nth 4 (decode-time now))
412                                       parse-time-months))))
413      (format-time-string "%Y %H:%M:%S " now)
414      ;; We do all of this because XEmacs doesn't have the %z spec.
415      (format "%s%02d%02d" sign (/ zone 3600) (/ (% zone 3600) 60)))))
416
417 (defun pop3-munge-message-separator (start end)
418   "Check to see if a message separator exists.  If not, generate one."
419   (save-excursion
420     (save-restriction
421       (narrow-to-region start end)
422       (goto-char (point-min))
423       (if (not (or (looking-at "From .?") ; Unix mail
424                    (looking-at "\001\001\001\001\n") ; MMDF
425                    (looking-at "BABYL OPTIONS:") ; Babyl
426                    ))
427           (let* ((from (mail-strip-quoted-names (mail-fetch-field "From")))
428                  (tdate (mail-fetch-field "Date"))
429                  (date (split-string (or (and tdate
430                                               (not (string= "" tdate))
431                                               tdate)
432                                          (pop3-make-date))
433                                      " "))
434                  (From_))
435             ;; sample date formats I have seen
436             ;; Date: Tue, 9 Jul 1996 09:04:21 -0400 (EDT)
437             ;; Date: 08 Jul 1996 23:22:24 -0400
438             ;; should be
439             ;; Tue Jul 9 09:04:21 1996
440
441             ;; Fixme: This should use timezone on the date field contents.
442             (setq date
443                   (cond ((not date)
444                          "Tue Jan 1 00:00:0 1900")
445                         ((string-match "[A-Z]" (nth 0 date))
446                          (format "%s %s %s %s %s"
447                                  (nth 0 date) (nth 2 date) (nth 1 date)
448                                  (nth 4 date) (nth 3 date)))
449                         (t
450                          ;; this really needs to be better but I don't feel
451                          ;; like writing a date to day converter.
452                          (format "Sun %s %s %s %s"
453                                  (nth 1 date) (nth 0 date)
454                                  (nth 3 date) (nth 2 date)))
455                         ))
456             (setq From_ (format "\nFrom %s  %s\n" from date))
457             (while (string-match "," From_)
458               (setq From_ (concat (substring From_ 0 (match-beginning 0))
459                                   (substring From_ (match-end 0)))))
460             (goto-char (point-min))
461             (insert From_)
462             (if (search-forward "\n\n" nil t)
463                 nil
464               (goto-char (point-max))
465               (insert "\n"))
466             (let ((size (- (point-max) (point))))
467               (forward-line -1)
468               (insert (format "Content-Length: %s\n" size)))
469             )))))
470
471 ;; The Command Set
472
473 ;; AUTHORIZATION STATE
474
475 (defun pop3-user (process user)
476   "Send USER information to POP3 server."
477   (pop3-send-command process (format "USER %s" user))
478   (let ((response (pop3-read-response process t)))
479     (if (not (and response (string-match "+OK" response)))
480         (error "USER %s not valid" user))))
481
482 (defun pop3-pass (process)
483   "Send authentication information to the server."
484   (pop3-send-command process (format "PASS %s" pop3-password))
485   (let ((response (pop3-read-response process t)))
486     (if (not (and response (string-match "+OK" response)))
487         (pop3-quit process))))
488
489 (defun pop3-apop (process user)
490   "Send alternate authentication information to the server."
491   (let ((pass pop3-password))
492     (if (and pop3-password-required (not pass))
493         (setq pass
494               (read-passwd (format "Password for %s: " pop3-maildrop))))
495     (if pass
496         (let ((hash (md5 (concat pop3-timestamp pass) nil nil 'binary)))
497           (pop3-send-command process (format "APOP %s %s" user hash))
498           (let ((response (pop3-read-response process t)))
499             (if (not (and response (string-match "+OK" response)))
500                 (pop3-quit process)))))
501     ))
502
503 ;; TRANSACTION STATE
504
505 (defun pop3-stat (process)
506   "Return the number of messages in the maildrop and the maildrop's size."
507   (pop3-send-command process "STAT")
508   (let ((response (pop3-read-response process t)))
509     (list (string-to-number (nth 1 (split-string response " ")))
510           (string-to-number (nth 2 (split-string response " "))))
511     ))
512
513 (defun pop3-list (process &optional msg)
514   "If MSG is nil, return an alist of (MESSAGE-ID . SIZE) pairs.
515 Otherwise, return the size of the message-id MSG"
516   (pop3-send-command process (if msg
517                                  (format "LIST %d" msg)
518                                "LIST"))
519   (let ((response (pop3-read-response process t)))
520     (if msg
521         (string-to-number (nth 2 (split-string response " ")))
522       (let ((start pop3-read-point) end)
523         (with-current-buffer (process-buffer process)
524           (while (not (re-search-forward "^\\.\r\n" nil t))
525             (pop3-accept-process-output process)
526             (goto-char start))
527           (setq pop3-read-point (point-marker))
528           (goto-char (match-beginning 0))
529           (setq end (point-marker))
530           (mapcar #'(lambda (s) (let ((split (split-string s " ")))
531                                   (cons (string-to-number (nth 0 split))
532                                         (string-to-number (nth 1 split)))))
533                   (split-string (buffer-substring start end) "\r\n" t)))))))
534
535 (defun pop3-retr (process msg crashbuf)
536   "Retrieve message-id MSG to buffer CRASHBUF."
537   (pop3-send-command process (format "RETR %s" msg))
538   (pop3-read-response process)
539   (let ((start pop3-read-point) end)
540     (with-current-buffer (process-buffer process)
541       (while (not (re-search-forward "^\\.\r\n" nil t))
542         (pop3-accept-process-output process)
543         (goto-char start))
544       (setq pop3-read-point (point-marker))
545       ;; this code does not seem to work for some POP servers...
546       ;; and I cannot figure out why not.
547       ;;      (goto-char (match-beginning 0))
548       ;;      (backward-char 2)
549       ;;      (if (not (looking-at "\r\n"))
550       ;;          (insert "\r\n"))
551       ;;      (re-search-forward "\\.\r\n")
552       (goto-char (match-beginning 0))
553       (setq end (point-marker))
554       (pop3-clean-region start end)
555       (pop3-munge-message-separator start end)
556       (with-current-buffer crashbuf
557         (erase-buffer))
558       (copy-to-buffer crashbuf start end)
559       (delete-region start end)
560       )))
561
562 (defun pop3-dele (process msg)
563   "Mark message-id MSG as deleted."
564   (pop3-send-command process (format "DELE %s" msg))
565   (pop3-read-response process))
566
567 (defun pop3-noop (process msg)
568   "No-operation."
569   (pop3-send-command process "NOOP")
570   (pop3-read-response process))
571
572 (defun pop3-last (process)
573   "Return highest accessed message-id number for the session."
574   (pop3-send-command process "LAST")
575   (let ((response (pop3-read-response process t)))
576     (string-to-number (nth 1 (split-string response " ")))
577     ))
578
579 (defun pop3-rset (process)
580   "Remove all delete marks from current maildrop."
581   (pop3-send-command process "RSET")
582   (pop3-read-response process))
583
584 ;; UPDATE
585
586 (defun pop3-quit (process)
587   "Close connection to POP3 server.
588 Tell server to remove all messages marked as deleted, unlock the maildrop,
589 and close the connection."
590   (pop3-send-command process "QUIT")
591   (pop3-read-response process t)
592   (if process
593       (with-current-buffer (process-buffer process)
594         (goto-char (point-max))
595         (delete-process process))))
596 \f
597 ;; Summary of POP3 (Post Office Protocol version 3) commands and responses
598
599 ;;; AUTHORIZATION STATE
600
601 ;; Initial TCP connection
602 ;; Arguments: none
603 ;; Restrictions: none
604 ;; Possible responses:
605 ;;  +OK [POP3 server ready]
606
607 ;; USER name
608 ;; Arguments: a server specific user-id (required)
609 ;; Restrictions: authorization state [after unsuccessful USER or PASS
610 ;; Possible responses:
611 ;;  +OK [valid user-id]
612 ;;  -ERR [invalid user-id]
613
614 ;; PASS string
615 ;; Arguments: a server/user-id specific password (required)
616 ;; Restrictions: authorization state, after successful USER
617 ;; Possible responses:
618 ;;  +OK [maildrop locked and ready]
619 ;;  -ERR [invalid password]
620 ;;  -ERR [unable to lock maildrop]
621
622 ;; STLS      (RFC 2595)
623 ;; Arguments: none
624 ;; Restrictions: Only permitted in AUTHORIZATION state.
625 ;; Possible responses:
626 ;;  +OK
627 ;;  -ERR
628
629 ;;; TRANSACTION STATE
630
631 ;; STAT
632 ;; Arguments: none
633 ;; Restrictions: transaction state
634 ;; Possible responses:
635 ;;  +OK nn mm [# of messages, size of maildrop]
636
637 ;; LIST [msg]
638 ;; Arguments: a message-id (optional)
639 ;; Restrictions: transaction state; msg must not be deleted
640 ;; Possible responses:
641 ;;  +OK [scan listing follows]
642 ;;  -ERR [no such message]
643
644 ;; RETR msg
645 ;; Arguments: a message-id (required)
646 ;; Restrictions: transaction state; msg must not be deleted
647 ;; Possible responses:
648 ;;  +OK [message contents follow]
649 ;;  -ERR [no such message]
650
651 ;; DELE msg
652 ;; Arguments: a message-id (required)
653 ;; Restrictions: transaction state; msg must not be deleted
654 ;; Possible responses:
655 ;;  +OK [message deleted]
656 ;;  -ERR [no such message]
657
658 ;; NOOP
659 ;; Arguments: none
660 ;; Restrictions: transaction state
661 ;; Possible responses:
662 ;;  +OK
663
664 ;; LAST
665 ;; Arguments: none
666 ;; Restrictions: transaction state
667 ;; Possible responses:
668 ;;  +OK nn [highest numbered message accessed]
669
670 ;; RSET
671 ;; Arguments: none
672 ;; Restrictions: transaction state
673 ;; Possible responses:
674 ;;  +OK [all delete marks removed]
675
676 ;;; UPDATE STATE
677
678 ;; QUIT
679 ;; Arguments: none
680 ;; Restrictions: none
681 ;; Possible responses:
682 ;;  +OK [TCP connection closed]
683
684 (provide 'pop3)
685
686 ;;; pop3.el ends here