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