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