1 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 ;; Free Software Foundation, Inc.
6 ;; Author: Richard L. Pieri <ratinox@peorth.gweep.net>
7 ;; Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Maintainer: Volunteers
12 ;; This file is part of T-gnus.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
31 ;; Most of the standard Post Office Protocol version 3 (RFC 1460) commands
32 ;; are implemented. The LIST command has not been implemented due to lack
33 ;; of actual usefulness.
34 ;; The optional POP3 command TOP has not been implemented.
36 ;; This program was inspired by Kyle E. Jones's vm-pop program.
38 ;; You have to set the variable `pop3-connection-type' to `ssl' or
39 ;; `tls' expressly, if you would like to use this module with Gnus
40 ;; (not T-gnus) for those connection types. For examples:
42 ;;(setq mail-sources '((pop :server "POPSERVER" :port 995 :connection ssl
43 ;; :authentication apop)))
44 ;;(setq pop3-connection-type 'ssl)
48 (eval-when-compile (require 'cl))
50 ;; as-binary-process, open-network-stream-as-binary, write-region-as-binary
57 (defvar pop3-maildrop (or (user-login-name) (getenv "LOGNAME") (getenv "USER") nil)
59 (defvar pop3-mailhost (or (getenv "MAILHOST") nil)
63 (defvar pop3-connection-type nil
64 "*POP3 connection type.")
66 (defvar pop3-password-required t
67 "*Non-nil if a password is required when connecting to POP server.")
68 (defvar pop3-password nil
69 "*Password to use when connecting to POP server.")
71 (defvar pop3-authentication-scheme 'pass
72 "*POP3 authentication scheme.
73 Defaults to 'pass, for the standard USER/PASS authentication. Other valid
76 (defvar pop3-timestamp nil
77 "Timestamp returned when initially connected to the POP server.
78 Used for APOP authentication.")
80 (defvar pop3-leave-mail-on-server nil
81 "Non-nil if mail is to be left on the server and UIDL used for message retrieval.")
83 (defvar pop3-maximum-message-size nil
84 "If non-nil only download messages smaller than this.")
86 (defvar pop3-except-header-regexp nil
87 "If non-nil we do not retrieve messages whose headers are matching this regexp.")
89 (defvar pop3-uidl-file-name "~/.uidls"
90 "File in which to store the UIDL of processed messages.")
92 (defvar pop3-uidl-support 'dont-know
93 "Whether the server supports UIDL.
94 Nil means no, t means yes, not-nil-or-t means yet to be determined.")
96 (defvar pop3-uidl-obarray (make-vector 31 0)
99 (defvar pop3-read-point nil)
100 (defvar pop3-debug nil)
103 (autoload 'open-ssl-stream "ssl")
104 (autoload 'starttls-open-stream "starttls")
105 (autoload 'starttls-negotiate "starttls"))
107 (defvar pop3-ssl-program-name
108 (if (exec-installed-p "openssl")
111 "The program to run in a subprocess to open an SSL connection.")
113 (defvar pop3-ssl-program-arguments
114 '("s_client" "-quiet")
115 "Arguments to be passed to the program `pop3-ssl-program-name'.")
117 (defun pop3-progress-message (format percent &rest args)
118 (apply (function message) format args))
120 (defun pop3-movemail (&optional crashbox)
121 "Transfer contents of a maildrop to the specified CRASHBOX."
122 (or crashbox (setq crashbox (expand-file-name "~/.crashbox")))
123 (let* ((process (pop3-open-server pop3-mailhost pop3-port))
124 (crashbuf (get-buffer-create " *pop3-retr*"))
127 (pop3-password pop3-password)
128 (pop3-uidl-file-name (convert-standard-filename
129 (concat pop3-uidl-file-name "-"
131 retrieved-messages messages)
132 ;; for debugging only
133 (if pop3-debug (switch-to-buffer (process-buffer process)))
134 ;; query for password
135 (if (and pop3-password-required (not pop3-password))
137 (pop3-read-passwd (format "Password for %s: " pop3-maildrop))))
138 (cond ((equal 'apop pop3-authentication-scheme)
139 (pop3-apop process pop3-maildrop))
140 ((equal 'pass pop3-authentication-scheme)
141 (pop3-user process pop3-maildrop)
143 (t (error "Invalid POP3 authentication scheme")))
144 ;; get messages that are suitable for download
145 (message "Retrieving message list...")
146 (setq messages (pop3-get-message-numbers process)
147 message-count (length (cdr messages)))
148 (message "Retrieving message list...%d of %d unread"
149 message-count (pop messages))
151 (unless (not (stringp crashbox))
153 (pop3-progress-message
154 "Retrieving message %d of %d (%d octets) from %s..."
155 (floor (* (/ (float n) message-count) 100))
156 n message-count (cdar messages) pop3-mailhost)
157 (pop3-retr process (caar messages) crashbuf)
158 (push (caar messages) retrieved-messages)
159 (setq messages (cdr messages)
161 (with-current-buffer crashbuf
162 (write-region-as-binary (point-min) (point-max)
163 crashbox 'append 'nomesg))
164 ;; mark messages as read
165 (when pop3-leave-mail-on-server
167 ;; now delete the messages we have retrieved
168 (unless pop3-leave-mail-on-server
169 (dolist (n retrieved-messages)
170 (message "Deleting message %d of %d from %s..."
171 n message-count pop3-mailhost)
172 (pop3-dele process n)))
175 (kill-buffer crashbuf)
178 (defun pop3-get-message-count ()
179 "Return the number of messages in the maildrop."
180 (let* ((process (pop3-open-server pop3-mailhost pop3-port))
182 (pop3-password pop3-password)
184 ;; for debugging only
185 (if pop3-debug (switch-to-buffer (process-buffer process)))
186 ;; query for password
187 (if (and pop3-password-required (not pop3-password))
189 (pop3-read-passwd (format "Password for %s: " pop3-maildrop))))
190 (cond ((equal 'apop pop3-authentication-scheme)
191 (pop3-apop process pop3-maildrop))
192 ((equal 'pass pop3-authentication-scheme)
193 (pop3-user process pop3-maildrop)
195 (t (error "Invalid POP3 authentication scheme")))
196 (setq message-count (car (pop3-stat process)))
200 (defun pop3-open-server (mailhost port)
201 "Open TCP connection to MAILHOST on PORT.
202 Returns the process associated with the connection.
203 Argument PORT specifies connecting port."
206 (set-buffer (get-buffer-create (concat " trace of POP session to "
209 (setq pop3-read-point (point-min))
213 ((eq pop3-connection-type 'ssl)
214 (pop3-open-ssl-stream "POP" (current-buffer) mailhost port))
215 ((eq pop3-connection-type 'tls)
216 (pop3-open-tls-stream "POP" (current-buffer) mailhost port))
218 (open-network-stream-as-binary "POP" (current-buffer)
220 (let ((response (pop3-read-response process t)))
222 (substring response (or (string-match "<" response) 0)
223 (+ 1 (or (string-match ">" response) -1)))))
226 (defun pop3-open-ssl-stream-1 (name buffer host service extra-arg)
227 (let* ((ssl-program-name
228 pop3-ssl-program-name)
229 (ssl-program-arguments
230 `(,@pop3-ssl-program-arguments
232 "-connect" ,(format "%s:%d" host service)))
233 (process (open-ssl-stream name buffer host service)))
235 (with-current-buffer buffer
236 (goto-char (point-min))
237 (while (and (memq (process-status process) '(open run))
238 (goto-char (point-max))
240 (not (looking-at "+OK")))
241 (accept-process-output process 1)
243 (delete-region (point-min) (point)))
244 (and process (memq (process-status process) '(open run))
247 (defun pop3-open-ssl-stream (name buffer host service)
248 "Open a SSL connection for a service to a host.
249 Returns a subprocess-object to represent the connection.
250 Args are NAME BUFFER HOST SERVICE."
252 (or (pop3-open-ssl-stream-1 name buffer host service "-ssl3")
253 (pop3-open-ssl-stream-1 name buffer host service "-ssl2"))))
255 (defun pop3-open-tls-stream (name buffer host service)
256 "Open a TLSv1 connection for a service to a host.
257 Returns a subprocess-object to represent the connection.
258 Args are NAME BUFFER HOST SERVICE."
260 (as-binary-process (starttls-open-stream
261 name buffer host service))))
263 (starttls-negotiate process)
268 (defun pop3-process-filter (process output)
270 (set-buffer (process-buffer process))
271 (goto-char (point-max))
274 (defun pop3-send-command (process command)
275 (set-buffer (process-buffer process))
276 (goto-char (point-max))
277 ;; (if (= (aref command 0) ?P)
278 ;; (insert "PASS <omitted>\r\n")
279 ;; (insert command "\r\n"))
280 (setq pop3-read-point (point))
281 (goto-char (point-max))
282 (process-send-string process (concat command "\r\n"))
285 (defun pop3-read-response (process &optional return)
286 "Read the response from the server PROCESS.
287 Return the response string if optional second argument RETURN is non-nil."
288 (let ((case-fold-search nil)
291 (set-buffer (process-buffer process))
292 (goto-char pop3-read-point)
293 (while (not (search-forward "\r\n" nil t))
294 (accept-process-output process 3)
295 (goto-char pop3-read-point))
296 (setq match-end (point))
297 (goto-char pop3-read-point)
298 (if (looking-at "-ERR")
299 (error (buffer-substring (point) (- match-end 2)))
300 (if (not (looking-at "+OK"))
301 (progn (setq pop3-read-point match-end) nil)
302 (setq pop3-read-point match-end)
304 (buffer-substring (point) match-end)
308 (defvar pop3-read-passwd nil)
309 (defun pop3-read-passwd (prompt)
310 (if (not pop3-read-passwd)
311 (if (fboundp 'read-passwd)
312 (setq pop3-read-passwd 'read-passwd)
313 (if (load "passwd" t)
314 (setq pop3-read-passwd 'read-passwd)
315 (autoload 'ange-ftp-read-passwd "ange-ftp")
316 (setq pop3-read-passwd 'ange-ftp-read-passwd))))
317 (funcall pop3-read-passwd prompt))
319 (defun pop3-clean-region (start end)
320 (setq end (set-marker (make-marker) end))
323 (while (and (< (point) end) (search-forward "\r\n" end t))
324 (replace-match "\n" t t))
326 (while (re-search-forward "\n\n\\(From \\)" end t)
327 (replace-match "\n\n>\\1" t nil))
329 (while (and (< (point) end) (re-search-forward "^\\." end t))
330 (replace-match "" t t)
332 (set-marker end nil))
334 (eval-when-compile (defvar parse-time-months))
336 ;; Copied from message-make-date.
337 (defun pop3-make-date (&optional now)
338 "Make a valid date header.
339 If NOW, use that time instead."
340 (require 'parse-time)
341 (let* ((now (or now (current-time)))
342 (zone (nth 8 (decode-time now)))
346 (setq zone (- zone)))
348 (format-time-string "%d" now)
349 ;; The month name of the %b spec is locale-specific. Pfff.
351 (capitalize (car (rassoc (nth 4 (decode-time now))
352 parse-time-months))))
353 (format-time-string "%Y %H:%M:%S " now)
354 ;; We do all of this because XEmacs doesn't have the %z spec.
355 (format "%s%02d%02d" sign (/ zone 3600) (/ (% zone 3600) 60)))))
357 (defun pop3-munge-message-separator (start end)
358 "Check to see if a message separator exists. If not, generate one."
361 (narrow-to-region start end)
362 (goto-char (point-min))
363 (if (not (or (looking-at "From .?") ; Unix mail
364 (looking-at "\001\001\001\001\n") ; MMDF
365 (looking-at "BABYL OPTIONS:") ; Babyl
367 (let* ((from (mail-strip-quoted-names (mail-fetch-field "From")))
368 (tdate (mail-fetch-field "Date"))
369 (date (split-string (or (and tdate
370 (not (string= "" tdate))
375 ;; sample date formats I have seen
376 ;; Date: Tue, 9 Jul 1996 09:04:21 -0400 (EDT)
377 ;; Date: 08 Jul 1996 23:22:24 -0400
379 ;; Tue Jul 9 09:04:21 1996
382 "Tue Jan 1 00:00:0 1900")
383 ((string-match "[A-Z]" (nth 0 date))
384 (format "%s %s %s %s %s"
385 (nth 0 date) (nth 2 date) (nth 1 date)
386 (nth 4 date) (nth 3 date)))
388 ;; this really needs to be better but I don't feel
389 ;; like writing a date to day converter.
390 (format "Sun %s %s %s %s"
391 (nth 1 date) (nth 0 date)
392 (nth 3 date) (nth 2 date)))
394 (setq From_ (format "\nFrom %s %s\n" from date))
395 (while (string-match "," From_)
396 (setq From_ (concat (substring From_ 0 (match-beginning 0))
397 (substring From_ (match-end 0)))))
398 (goto-char (point-min))
400 (if (search-forward "\n\n" nil t)
402 (goto-char (point-max))
404 (narrow-to-region (point) (point-max))
405 (let ((size (- (point-max) (point-min))))
406 (goto-char (point-min))
409 (insert (format "Content-Length: %s\n" size)))
414 (defun pop3-get-message-numbers (process)
415 "Get the list of message numbers and lengths to retrieve via PROCESS."
416 ;; we use the LIST comand first anyway to get the message lengths.
417 ;; then if we're leaving mail on the server, see if the UIDL command
418 ;; is implemented. if so, we use it to get the message number list.
419 (let* ((messages (pop3-list process))
420 (total (or (pop messages) 0))
421 (uidl (if pop3-leave-mail-on-server
422 (pop3-get-uidl process)))
425 ;; only retrieve messages matching our regexp or in the uidl list
427 ;; remove elements not in the uidl, this assumes the uidl is short
428 (or (not (eq pop3-uidl-support t))
429 (memq (caar messages) uidl))
431 ;; don't download messages that are too large
432 (not (and pop3-maximum-message-size
433 (> (cdar messages) pop3-maximum-message-size)))
434 (not (and pop3-except-header-regexp
435 (string-match pop3-except-header-regexp
436 (pop3-top process (caar messages) 0)))))
437 (push (car messages) out))
438 (setq messages (cdr messages)))
439 (cons total (reverse out))))
441 (defun pop3-get-uidl (process)
442 "Use PROCESS to get a list of unread message numbers."
443 (let ((messages (pop3-uidl process)) uidl)
444 (if (or (null messages) (null pop3-uidl-support))
445 (setq pop3-uidl-support nil)
446 (setq pop3-uidl-support t)
449 (when (file-readable-p pop3-uidl-file-name)
450 (insert-file-contents pop3-uidl-file-name))
451 (goto-char (point-min))
452 (while (looking-at "\\([^ \n\t]+\\)")
453 (set (intern (match-string 1) pop3-uidl-obarray)
457 (dolist (message (cdr messages))
458 (if (setq uidl (intern-soft (cdr message) pop3-uidl-obarray))
459 (setcar (symbol-value uidl) (car message))
460 (set (intern (cdr message) pop3-uidl-obarray)
461 (cons (car message) nil))))
462 (pop3-get-unread-message-numbers))
465 (defun pop3-get-unread-message-numbers ()
466 "Return a sorted list of unread msg numbers to retrieve."
468 (mapatoms (lambda (atom)
469 (if (not (cdr (symbol-value atom)))
470 (push (car (symbol-value atom)) nums)))
474 (defun pop3-save-uidls ()
475 "Save the updated UIDLs to disk for use next time."
476 (when (and pop3-leave-mail-on-server
477 ;; UIDL hash table is non-empty
478 (let ((len (length pop3-uidl-obarray)))
480 (setq len (if (symbolp (aref pop3-uidl-obarray (1- len)))
483 (when (file-readable-p pop3-uidl-file-name)
484 (copy-file pop3-uidl-file-name
485 (concat pop3-uidl-file-name ".old")
486 'overwrite 'keeptime))
488 (with-temp-file pop3-uidl-file-name
491 (when (car (symbol-value atom))
492 (insert (format "%s\n" atom))))
494 (fillarray pop3-uidl-obarray 0)))
499 ;; AUTHORIZATION STATE
501 (defun pop3-user (process user)
502 "Send USER information to POP3 server."
503 (pop3-send-command process (format "USER %s" user))
504 (let ((response (pop3-read-response process t)))
505 (if (not (and response (string-match "+OK" response)))
506 (error (format "USER %s not valid" user)))))
508 (defun pop3-pass (process)
509 "Send authentication information to the server."
510 (pop3-send-command process (format "PASS %s" pop3-password))
511 (let ((response (pop3-read-response process t)))
512 (if (not (and response (string-match "+OK" response)))
513 (pop3-quit process))))
515 ;; When this file is being compiled in the Gnus (not T-gnus) source
516 ;; tree, `md5' might have been defined in w3/md5.el, ./lpath.el or one
517 ;; of some other libraries and `md5' will accept only 3 arguments. We
518 ;; will deceive the byte-compiler not to say warnings.
520 (if (fboundp 'eval-when)
521 ;; `eval-when' might not be provided when loading .el file.
523 (let ((def (assq 'md5 byte-compile-function-environment)))
525 (setcdr def '(lambda (object &optional start end
526 coding-system noerror)))
527 (setq byte-compile-function-environment
528 (cons '(md5 . (lambda (object &optional start end
529 coding-system noerror)))
530 byte-compile-function-environment)))))))
532 ;; Note that `pop3-md5' should never encode a given string to use for
533 ;; the apop authentication.
536 (if (condition-case nil
538 Check whether the 4th argument CODING-SYSTEM is allowed"
541 ;; Emacs 21 or XEmacs 21
542 ;; (md5 OBJECT &optional START END CODING-SYSTEM NOERROR)
543 (defun pop3-md5 (string)
544 (md5 string nil nil 'binary))
545 ;; The reason why the program reaches here:
546 ;; 1. XEmacs 20 is running and the built-in `md5' doesn't
547 ;; allow the 4th argument.
548 ;; 2. `md5' has been defined by one of some lisp libraries.
549 ;; 3. This file is being compiled in the Gnus source tree,
550 ;; and `md5' has been defined in lpath.el.
551 (defalias 'pop3-md5 'md5))
552 ;; The lisp function will be provided by FLIM or other libraries.
553 (autoload 'md5 "md5")
554 (defalias 'pop3-md5 'md5)))
556 (defun pop3-apop (process user)
557 "Send alternate authentication information to the server."
558 (let ((pass pop3-password))
559 (if (and pop3-password-required (not pass))
561 (pop3-read-passwd (format "Password for %s: " pop3-maildrop))))
563 (let ((hash (pop3-md5 (concat pop3-timestamp pass))))
564 (pop3-send-command process (format "APOP %s %s" user hash))
565 (let ((response (pop3-read-response process t)))
566 (if (not (and response (string-match "+OK" response)))
567 (pop3-quit process)))))
570 (defun pop3-stls (process)
571 "Query whether TLS extension is supported"
572 (pop3-send-command process "STLS")
573 (let ((response (pop3-read-response process t)))
574 (if (not (and response (string-match "+OK" response)))
575 (pop3-quit process))))
579 (defun pop3-stat (process)
580 "Return the number of messages in the maildrop and the maildrop's size."
581 (pop3-send-command process "STAT")
582 (let ((response (pop3-read-response process t)))
583 (list (string-to-int (nth 1 (split-string response " ")))
584 (string-to-int (nth 2 (split-string response " "))))
587 (defun pop3-retr (process msg crashbuf)
588 "Retrieve message-id MSG to buffer CRASHBUF."
589 (pop3-send-command process (format "RETR %s" msg))
590 (pop3-read-response process)
592 (let ((region (pop3-get-extended-response process)))
593 (pop3-munge-message-separator (car region) (cadr region))
594 (append-to-buffer crashbuf (car region) (cadr region))
595 (delete-region (car region) (cadr region))
598 (defun pop3-dele (process msg)
599 "Mark message-id MSG as deleted."
600 (pop3-send-command process (format "DELE %s" msg))
601 (pop3-read-response process))
603 (defun pop3-noop (process msg)
605 (pop3-send-command process "NOOP")
606 (pop3-read-response process))
608 (defun pop3-last (process)
609 "Return highest accessed message-id number for the session."
610 (pop3-send-command process "LAST")
611 (let ((response (pop3-read-response process t)))
612 (string-to-int (nth 1 (split-string response " ")))
615 (defun pop3-rset (process)
616 "Remove all delete marks from current maildrop."
617 (pop3-send-command process "RSET")
618 (pop3-read-response process))
622 (defun pop3-quit (process)
623 "Close connection to POP3 server.
624 Tell server to remove all messages marked as deleted, unlock the maildrop,
625 and close the connection."
626 (pop3-send-command process "QUIT")
627 (pop3-read-response process t)
630 (set-buffer (process-buffer process))
631 (goto-char (point-max))
632 (delete-process process))))
634 (defun pop3-uidl (process &optional msgno)
635 "Return the results of a UIDL command in PROCESS for optional MSGNO.
636 If UIDL is unsupported on this mail server or if msgno is invalid, return nil.
637 Otherwise, return a list in the form
639 (N (1 UIDL-1) (2 UIDL-2) ... (N UIDL-N))
643 N is an integer for the number of UIDLs returned (could be 0)
647 (pop3-send-command process (format "UIDL %d" msgno))
648 (pop3-send-command process "UIDL"))
650 (if (null (pop3-read-response process t))
651 nil ;; UIDL is not supported on this server
655 (apply 'narrow-to-region (pop3-get-extended-response process))
656 (goto-char (point-min))
657 (while (looking-at "\\([^ \n\t]*\\) \\([^ \n\t]*\\)")
658 (setq msgno (string-to-int (match-string 1))
659 uidl (match-string 2))
660 (push (cons msgno uidl) pairs)
661 (beginning-of-line 2))
662 (cons (length pairs) (nreverse pairs))
665 (defun pop3-list (process &optional msgno)
666 "Return the results of a LIST command for PROCESS and optional MSGNO.
667 If (optional) msgno is invalid, return nil. Otherwise, return a list
670 (N (1 LEN-1) (2 LEN-2) ... (N LEN-N))
674 N is an integer for the number of msg/len pairs (could be 0)
675 LEN-n is an integer."
677 (pop3-send-command process (format "LIST %d" msgno))
678 (pop3-send-command process "LIST"))
680 (if (null (pop3-read-response process t))
681 nil ;; MSGNO is not valid number
685 (apply 'narrow-to-region (pop3-get-extended-response process))
686 (goto-char (point-min))
687 (while (looking-at "\\([^ \n\t]*\\) \\([^ \n\t]*\\)")
688 (setq msgno (string-to-int (match-string 1))
689 len (string-to-int (match-string 2)))
690 (push (cons msgno len) pairs)
691 (beginning-of-line 2))
692 (cons (length pairs) (nreverse pairs))
695 (defun pop3-top (process msgno &optional lines)
696 "Return the top LINES of messages for PROCESS and MSGNO.
697 If msgno is invalid, return nil. Otherwise, return a string."
698 (pop3-send-command process (format "TOP %d %d" msgno (or lines 1)))
699 (if (pop3-read-response process t)
700 nil ;; MSGNO is not valid number
702 (apply 'buffer-substring (pop3-get-extended-response process)))
707 (defun pop3-get-extended-response (process)
708 "Get the extended pop3 response in the PROCESS buffer."
709 (let ((start pop3-read-point) end)
710 (set-buffer (process-buffer process))
712 (while (not (re-search-forward "^\\.\r\n" nil t))
713 (accept-process-output process 3)
715 (setq pop3-read-point (point-marker))
716 (goto-char (match-beginning 0))
717 (setq end (point-marker))
718 (pop3-clean-region start end)
722 ;; Summary of POP3 (Post Office Protocol version 3) commands and responses
724 ;;; AUTHORIZATION STATE
726 ;; Initial TCP connection
728 ;; Restrictions: none
729 ;; Possible responses:
730 ;; +OK [POP3 server ready]
733 ;; Arguments: a server specific user-id (required)
734 ;; Restrictions: authorization state [after unsuccessful USER or PASS
735 ;; Possible responses:
736 ;; +OK [valid user-id]
737 ;; -ERR [invalid user-id]
740 ;; Arguments: a server/user-id specific password (required)
741 ;; Restrictions: authorization state, after successful USER
742 ;; Possible responses:
743 ;; +OK [maildrop locked and ready]
744 ;; -ERR [invalid password]
745 ;; -ERR [unable to lock maildrop]
749 ;; Restrictions: authorization state
750 ;; Possible responses:
751 ;; +OK [negotiation is ready]
752 ;; -ERR [security layer is already active]
754 ;;; TRANSACTION STATE
758 ;; Restrictions: transaction state
759 ;; Possible responses:
760 ;; +OK nn mm [# of messages, size of maildrop]
763 ;; Arguments: a message-id (optional)
764 ;; Restrictions: transaction state; msg must not be deleted
765 ;; Possible responses:
766 ;; +OK [scan listing follows]
767 ;; -ERR [no such message]
770 ;; Arguments: a message-id (required), number of lines (optional)
771 ;; Restrictions: transaction state; msg must not be deleted
772 ;; Possible responses:
773 ;; +OK [partial message listing follows]
774 ;; -ERR [no such message]
777 ;; Arguments: a message-id (optional)
778 ;; Restrictions: transaction state; msg must not be deleted
779 ;; Possible responses:
780 ;; +OK [uidl listing follows]
781 ;; -ERR [no such message]
784 ;; Arguments: a message-id (required)
785 ;; Restrictions: transaction state; msg must not be deleted
786 ;; Possible responses:
787 ;; +OK [message contents follow]
788 ;; -ERR [no such message]
791 ;; Arguments: a message-id (required)
792 ;; Restrictions: transaction state; msg must not be deleted
793 ;; Possible responses:
794 ;; +OK [message deleted]
795 ;; -ERR [no such message]
799 ;; Restrictions: transaction state
800 ;; Possible responses:
805 ;; Restrictions: transaction state
806 ;; Possible responses:
807 ;; +OK nn [highest numbered message accessed]
811 ;; Restrictions: transaction state
812 ;; Possible responses:
813 ;; +OK [all delete marks removed]
819 ;; Restrictions: none
820 ;; Possible responses:
821 ;; +OK [TCP connection closed]
825 ;;; pop3.el ends here