Mercurial > emacs
annotate lisp/gnus/pop3.el @ 63436:eca4e949db45
(iswitchb-to-end): Replace mapcar with dolist.
(iswitchb-get-matched-buffers): Likewise. Simplify.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 14 Jun 2005 15:51:11 +0000 |
parents | 31ebc6690b8b |
children | 91a6c1b5b3c4 01137c1fdbe9 |
rev | line source |
---|---|
17493 | 1 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface |
2 | |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
4 ;; 2005 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
28835
diff
changeset
|
5 ;; Free Software Foundation, Inc. |
17493 | 6 |
7 ;; Author: Richard L. Pieri <ratinox@peorth.gweep.net> | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
8 ;; Maintainer: FSF |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
9 ;; Keywords: mail |
17493 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Commentary: | |
29 | |
30 ;; Most of the standard Post Office Protocol version 3 (RFC 1460) commands | |
31 ;; are implemented. The LIST command has not been implemented due to lack | |
32 ;; of actual usefulness. | |
33 ;; The optional POP3 command TOP has not been implemented. | |
34 | |
35 ;; This program was inspired by Kyle E. Jones's vm-pop program. | |
36 | |
37 ;;; Code: | |
38 | |
39 (require 'mail-utils) | |
40 | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
41 (defgroup pop3 nil |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
42 "Post Office Protocol" |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
43 :group 'mail |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
44 :group 'mail-source) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
45 |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
46 (defcustom pop3-maildrop (or (user-login-name) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
47 (getenv "LOGNAME") |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
48 (getenv "USER")) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
49 "*POP3 maildrop." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
50 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
51 :type 'string |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
52 :group 'pop3) |
17493 | 53 |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
54 (defcustom pop3-mailhost (or (getenv "MAILHOST") ;; nil -> mismatch |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
55 "pop3") |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
56 "*POP3 mailhost." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
57 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
58 :type 'string |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
59 :group 'pop3) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
60 |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
61 (defcustom pop3-port 110 |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
62 "*POP3 port." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
63 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
64 :type 'number |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
65 :group 'pop3) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
66 |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
67 (defcustom pop3-password-required t |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
68 "*Non-nil if a password is required when connecting to POP server." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
69 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
70 :type 'boolean |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
71 :group 'pop3) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
72 |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
73 ;; Should this be customizable? |
17493 | 74 (defvar pop3-password nil |
75 "*Password to use when connecting to POP server.") | |
76 | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
77 (defcustom pop3-authentication-scheme 'pass |
17493 | 78 "*POP3 authentication scheme. |
79 Defaults to 'pass, for the standard USER/PASS authentication. Other valid | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
80 values are 'apop." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
81 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
82 :type '(choice (const :tag "USER/PASS" pass) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
83 (const :tag "APOP" apop)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
84 :group 'pop3) |
17493 | 85 |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
86 (defcustom pop3-leave-mail-on-server nil |
57561
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
87 "*Non-nil if the mail is to be left on the POP server after fetching. |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
88 |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
89 If the `pop3-leave-mail-on-server' is non-`nil' the mail is to be |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
90 left on the POP server after fetching. Note that POP servers |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
91 maintain no state information between sessions, so what the |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
92 client believes is there and what is actually there may not match |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
93 up. If they do not, then the whole thing can fall apart and |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
94 leave you with a corrupt mailbox." |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
58835
diff
changeset
|
95 :version "22.1" ;; Oort Gnus |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
96 :type 'boolean |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
97 :group 'pop3) |
51546
a5038d551293
(pop3-leave-mail-on-server): New user variable.
Sam Steingold <sds@gnu.org>
parents:
44544
diff
changeset
|
98 |
17493 | 99 (defvar pop3-timestamp nil |
100 "Timestamp returned when initially connected to the POP server. | |
101 Used for APOP authentication.") | |
102 | |
103 (defvar pop3-read-point nil) | |
104 (defvar pop3-debug nil) | |
105 | |
57561
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
106 ;; Borrowed from nnheader-accept-process-output in nnheader.el. |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
107 (defvar pop3-read-timeout |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
108 (if (string-match "windows-nt\\|os/2\\|emx\\|cygwin" |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
109 (symbol-name system-type)) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
110 ;; http://thread.gmane.org/v9655t3pjo.fsf@marauder.physik.uni-ulm.de |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
111 ;; |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
112 ;; IIRC, values lower than 1.0 didn't/don't work on Windows/DOS. |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
113 ;; |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
114 ;; There should probably be a runtime test to determine the timing |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
115 ;; resolution, or a primitive to report it. I don't know off-hand |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
116 ;; what's possible. Perhaps better, maybe the Windows/DOS primitive |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
117 ;; could round up non-zero timeouts to a minimum of 1.0? |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
118 1.0 |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
119 0.1) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
120 "How long pop3 should wait between checking for the end of output. |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
121 Shorter values mean quicker response, but are more CPU intensive.") |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
122 |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
123 ;; Borrowed from nnheader-accept-process-output in nnheader.el. |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
124 (defun pop3-accept-process-output (process) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
125 (accept-process-output |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
126 process |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
127 (truncate pop3-read-timeout) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
128 (truncate (* (- pop3-read-timeout |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
129 (truncate pop3-read-timeout)) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
130 1000)))) |
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
131 |
17493 | 132 (defun pop3-movemail (&optional crashbox) |
133 "Transfer contents of a maildrop to the specified CRASHBOX." | |
134 (or crashbox (setq crashbox (expand-file-name "~/.crashbox"))) | |
135 (let* ((process (pop3-open-server pop3-mailhost pop3-port)) | |
136 (crashbuf (get-buffer-create " *pop3-retr*")) | |
137 (n 1) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
138 message-count |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
139 (pop3-password pop3-password)) |
17493 | 140 ;; for debugging only |
141 (if pop3-debug (switch-to-buffer (process-buffer process))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
142 ;; query for password |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
143 (if (and pop3-password-required (not pop3-password)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
144 (setq pop3-password |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
145 (read-passwd (format "Password for %s: " pop3-maildrop)))) |
17493 | 146 (cond ((equal 'apop pop3-authentication-scheme) |
147 (pop3-apop process pop3-maildrop)) | |
148 ((equal 'pass pop3-authentication-scheme) | |
149 (pop3-user process pop3-maildrop) | |
150 (pop3-pass process)) | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
151 (t (error "Invalid POP3 authentication scheme"))) |
17493 | 152 (setq message-count (car (pop3-stat process))) |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
153 (unwind-protect |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
154 (while (<= n message-count) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
155 (message "Retrieving message %d of %d from %s..." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
156 n message-count pop3-mailhost) |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
157 (pop3-retr process n crashbuf) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
158 (save-excursion |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
159 (set-buffer crashbuf) |
34618
81ecf6fce11a
2000-12-15 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
33369
diff
changeset
|
160 (let ((coding-system-for-write 'binary)) |
26944
64597461b498
(pop3-movemail-file-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents:
26108
diff
changeset
|
161 (write-region (point-min) (point-max) crashbox t 'nomesg)) |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
162 (set-buffer (process-buffer process)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
163 (while (> (buffer-size) 5000) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
164 (goto-char (point-min)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
165 (forward-line 50) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
166 (delete-region (point-min) (point)))) |
51546
a5038d551293
(pop3-leave-mail-on-server): New user variable.
Sam Steingold <sds@gnu.org>
parents:
44544
diff
changeset
|
167 (unless pop3-leave-mail-on-server |
a5038d551293
(pop3-leave-mail-on-server): New user variable.
Sam Steingold <sds@gnu.org>
parents:
44544
diff
changeset
|
168 (pop3-dele process n)) |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
169 (setq n (+ 1 n)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
170 (if pop3-debug (sit-for 1) (sit-for 0.1)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
171 ) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
172 (pop3-quit process)) |
17493 | 173 (kill-buffer crashbuf) |
174 ) | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
175 t) |
17493 | 176 |
35453
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
177 (defun pop3-get-message-count () |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
178 "Return the number of messages in the maildrop." |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
179 (let* ((process (pop3-open-server pop3-mailhost pop3-port)) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
180 message-count |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
181 (pop3-password pop3-password)) |
35453
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
182 ;; for debugging only |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
183 (if pop3-debug (switch-to-buffer (process-buffer process))) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
184 ;; query for password |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
185 (if (and pop3-password-required (not pop3-password)) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
186 (setq pop3-password |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
187 (read-passwd (format "Password for %s: " pop3-maildrop)))) |
35453
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
188 (cond ((equal 'apop pop3-authentication-scheme) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
189 (pop3-apop process pop3-maildrop)) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
190 ((equal 'pass pop3-authentication-scheme) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
191 (pop3-user process pop3-maildrop) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
192 (pop3-pass process)) |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
35453
diff
changeset
|
193 (t (error "Invalid POP3 authentication scheme"))) |
35453
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
194 (setq message-count (car (pop3-stat process))) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
195 (pop3-quit process) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
196 message-count)) |
26726eff41ca
2001-01-21 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
34618
diff
changeset
|
197 |
17493 | 198 (defun pop3-open-server (mailhost port) |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
199 "Open TCP connection to MAILHOST on PORT. |
17493 | 200 Returns the process associated with the connection." |
28835 | 201 (let ((coding-system-for-read 'binary) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
202 (coding-system-for-write 'binary) |
28835 | 203 process) |
17493 | 204 (save-excursion |
28835 | 205 (set-buffer (get-buffer-create (concat " trace of POP session to " |
206 mailhost))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
207 (erase-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
208 (setq pop3-read-point (point-min)) |
44544
a5381c78296d
(pop3-open-server): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
44541
diff
changeset
|
209 (setq process (open-network-stream "POP" (current-buffer) mailhost port)) |
28835 | 210 (let ((response (pop3-read-response process t))) |
211 (setq pop3-timestamp | |
212 (substring response (or (string-match "<" response) 0) | |
213 (+ 1 (or (string-match ">" response) -1))))) | |
214 process))) | |
17493 | 215 |
216 ;; Support functions | |
217 | |
218 (defun pop3-process-filter (process output) | |
219 (save-excursion | |
220 (set-buffer (process-buffer process)) | |
221 (goto-char (point-max)) | |
222 (insert output))) | |
223 | |
224 (defun pop3-send-command (process command) | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
225 (set-buffer (process-buffer process)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
226 (goto-char (point-max)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
227 ;; (if (= (aref command 0) ?P) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
228 ;; (insert "PASS <omitted>\r\n") |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
229 ;; (insert command "\r\n")) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
230 (setq pop3-read-point (point)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
231 (goto-char (point-max)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
232 (process-send-string process (concat command "\r\n"))) |
17493 | 233 |
234 (defun pop3-read-response (process &optional return) | |
235 "Read the response from the server. | |
236 Return the response string if optional second argument is non-nil." | |
237 (let ((case-fold-search nil) | |
238 match-end) | |
239 (save-excursion | |
240 (set-buffer (process-buffer process)) | |
241 (goto-char pop3-read-point) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
242 (while (and (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
243 (not (search-forward "\r\n" nil t))) |
57561
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
244 (pop3-accept-process-output process) |
17493 | 245 (goto-char pop3-read-point)) |
246 (setq match-end (point)) | |
247 (goto-char pop3-read-point) | |
248 (if (looking-at "-ERR") | |
249 (error (buffer-substring (point) (- match-end 2))) | |
250 (if (not (looking-at "+OK")) | |
251 (progn (setq pop3-read-point match-end) nil) | |
252 (setq pop3-read-point match-end) | |
253 (if return | |
254 (buffer-substring (point) match-end) | |
255 t) | |
256 ))))) | |
257 | |
258 (defun pop3-clean-region (start end) | |
259 (setq end (set-marker (make-marker) end)) | |
260 (save-excursion | |
261 (goto-char start) | |
262 (while (and (< (point) end) (search-forward "\r\n" end t)) | |
263 (replace-match "\n" t t)) | |
264 (goto-char start) | |
265 (while (and (< (point) end) (re-search-forward "^\\." end t)) | |
266 (replace-match "" t t) | |
267 (forward-char))) | |
268 (set-marker end nil)) | |
269 | |
33369 | 270 (eval-when-compile (defvar parse-time-months)) |
271 | |
272 ;; Copied from message-make-date. | |
273 (defun pop3-make-date (&optional now) | |
274 "Make a valid date header. | |
275 If NOW, use that time instead." | |
276 (require 'parse-time) | |
277 (let* ((now (or now (current-time))) | |
278 (zone (nth 8 (decode-time now))) | |
279 (sign "+")) | |
280 (when (< zone 0) | |
281 (setq sign "-") | |
282 (setq zone (- zone))) | |
283 (concat | |
284 (format-time-string "%d" now) | |
285 ;; The month name of the %b spec is locale-specific. Pfff. | |
286 (format " %s " | |
287 (capitalize (car (rassoc (nth 4 (decode-time now)) | |
288 parse-time-months)))) | |
289 (format-time-string "%Y %H:%M:%S " now) | |
290 ;; We do all of this because XEmacs doesn't have the %z spec. | |
291 (format "%s%02d%02d" sign (/ zone 3600) (/ (% zone 3600) 60))))) | |
292 | |
17493 | 293 (defun pop3-munge-message-separator (start end) |
294 "Check to see if a message separator exists. If not, generate one." | |
295 (save-excursion | |
296 (save-restriction | |
297 (narrow-to-region start end) | |
298 (goto-char (point-min)) | |
299 (if (not (or (looking-at "From .?") ; Unix mail | |
300 (looking-at "\001\001\001\001\n") ; MMDF | |
301 (looking-at "BABYL OPTIONS:") ; Babyl | |
302 )) | |
44541
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
303 (let* ((from (mail-strip-quoted-names (mail-fetch-field "From"))) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
304 (tdate (mail-fetch-field "Date")) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
305 (date (split-string (or (and tdate |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
306 (not (string= "" tdate)) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
307 tdate) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
308 (pop3-make-date)) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
309 " ")) |
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
310 (From_)) |
17493 | 311 ;; sample date formats I have seen |
312 ;; Date: Tue, 9 Jul 1996 09:04:21 -0400 (EDT) | |
313 ;; Date: 08 Jul 1996 23:22:24 -0400 | |
314 ;; should be | |
315 ;; Tue Jul 9 09:04:21 1996 | |
316 (setq date | |
44541
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
317 (cond ((not date) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
318 "Tue Jan 1 00:00:0 1900") |
44541
1910e7c74f9f
* pop3.el (pop3-munge-message-separator): Work if no date.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
44452
diff
changeset
|
319 ((string-match "[A-Z]" (nth 0 date)) |
17493 | 320 (format "%s %s %s %s %s" |
321 (nth 0 date) (nth 2 date) (nth 1 date) | |
322 (nth 4 date) (nth 3 date))) | |
323 (t | |
324 ;; this really needs to be better but I don't feel | |
325 ;; like writing a date to day converter. | |
326 (format "Sun %s %s %s %s" | |
327 (nth 1 date) (nth 0 date) | |
328 (nth 3 date) (nth 2 date))) | |
329 )) | |
330 (setq From_ (format "\nFrom %s %s\n" from date)) | |
331 (while (string-match "," From_) | |
332 (setq From_ (concat (substring From_ 0 (match-beginning 0)) | |
333 (substring From_ (match-end 0))))) | |
334 (goto-char (point-min)) | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
335 (insert From_) |
33369 | 336 (if (search-forward "\n\n" nil t) |
337 nil | |
338 (goto-char (point-max)) | |
339 (insert "\n")) | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
340 (narrow-to-region (point) (point-max)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
341 (let ((size (- (point-max) (point-min)))) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
342 (goto-char (point-min)) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
343 (widen) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
344 (forward-line -1) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
345 (insert (format "Content-Length: %s\n" size))) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
346 ))))) |
17493 | 347 |
348 ;; The Command Set | |
349 | |
350 ;; AUTHORIZATION STATE | |
351 | |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
352 (eval-when-compile |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
353 (if (not (fboundp 'md5)) ;; Emacs 20 |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
354 (defalias 'md5 'ignore))) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
355 |
58835
9bdd97960431
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Miles Bader <miles@gnu.org>
parents:
57561
diff
changeset
|
356 (eval-and-compile |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
357 (if (and (fboundp 'md5) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
358 ;; There might be an incompatible implementation. |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
359 (condition-case nil |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
360 (md5 "Check whether the 4th argument is allowed" |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
361 nil nil 'binary) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
362 (error nil))) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
363 (defun pop3-md5 (string) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
364 (md5 string nil nil 'binary)) |
58835
9bdd97960431
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Miles Bader <miles@gnu.org>
parents:
57561
diff
changeset
|
365 (defvar pop3-md5-program "md5" |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
366 "*Program to encode its input in MD5. |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
367 \"openssl\" is a popular alternative; set `pop3-md5-program-args' to |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
368 '(\"md5\") if you use it.") |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
369 (defvar pop3-md5-program-args nil |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
370 "*List of arguments passed to `pop3-md5-program'.") |
58835
9bdd97960431
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Miles Bader <miles@gnu.org>
parents:
57561
diff
changeset
|
371 (defun pop3-md5 (string) |
62960
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
372 (let ((default-enable-multibyte-characters t) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
373 (coding-system-for-write 'binary)) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
374 (with-temp-buffer |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
375 (insert string) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
376 (apply 'call-process-region (point-min) (point-max) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
377 pop3-md5-program t (current-buffer) nil |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
378 pop3-md5-program-args) |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
379 ;; The meaningful output is the first 32 characters. |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
380 ;; Don't return the newline that follows them! |
31ebc6690b8b
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-348
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
381 (buffer-substring (point-min) (+ 32 (point-min)))))))) |
58835
9bdd97960431
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716
Miles Bader <miles@gnu.org>
parents:
57561
diff
changeset
|
382 |
17493 | 383 (defun pop3-user (process user) |
384 "Send USER information to POP3 server." | |
385 (pop3-send-command process (format "USER %s" user)) | |
386 (let ((response (pop3-read-response process t))) | |
387 (if (not (and response (string-match "+OK" response))) | |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
35453
diff
changeset
|
388 (error (format "USER %s not valid" user))))) |
17493 | 389 |
390 (defun pop3-pass (process) | |
391 "Send authentication information to the server." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
392 (pop3-send-command process (format "PASS %s" pop3-password)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
393 (let ((response (pop3-read-response process t))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
394 (if (not (and response (string-match "+OK" response))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23435
diff
changeset
|
395 (pop3-quit process)))) |
19633
25317a11d7a1
(pop3-md5): New function.
Richard M. Stallman <rms@gnu.org>
parents:
19595
diff
changeset
|
396 |
17493 | 397 (defun pop3-apop (process user) |
398 "Send alternate authentication information to the server." | |
399 (let ((pass pop3-password)) | |
400 (if (and pop3-password-required (not pass)) | |
401 (setq pass | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
402 (read-passwd (format "Password for %s: " pop3-maildrop)))) |
17493 | 403 (if pass |
19633
25317a11d7a1
(pop3-md5): New function.
Richard M. Stallman <rms@gnu.org>
parents:
19595
diff
changeset
|
404 (let ((hash (pop3-md5 (concat pop3-timestamp pass)))) |
17493 | 405 (pop3-send-command process (format "APOP %s %s" user hash)) |
406 (let ((response (pop3-read-response process t))) | |
407 (if (not (and response (string-match "+OK" response))) | |
408 (pop3-quit process))))) | |
409 )) | |
410 | |
411 ;; TRANSACTION STATE | |
412 | |
413 (defun pop3-stat (process) | |
414 "Return the number of messages in the maildrop and the maildrop's size." | |
415 (pop3-send-command process "STAT") | |
416 (let ((response (pop3-read-response process t))) | |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
417 (list (string-to-number (nth 1 (split-string response " "))) |
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
418 (string-to-number (nth 2 (split-string response " ")))) |
17493 | 419 )) |
420 | |
421 (defun pop3-list (process &optional msg) | |
422 "Scan listing of available messages. | |
423 This function currently does nothing.") | |
424 | |
425 (defun pop3-retr (process msg crashbuf) | |
426 "Retrieve message-id MSG to buffer CRASHBUF." | |
427 (pop3-send-command process (format "RETR %s" msg)) | |
428 (pop3-read-response process) | |
429 (let ((start pop3-read-point) end) | |
430 (save-excursion | |
431 (set-buffer (process-buffer process)) | |
432 (while (not (re-search-forward "^\\.\r\n" nil t)) | |
57561
505c55fe8dc9
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-621
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
433 (pop3-accept-process-output process) |
17493 | 434 (goto-char start)) |
435 (setq pop3-read-point (point-marker)) | |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
436 ;; this code does not seem to work for some POP servers... |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
437 ;; and I cannot figure out why not. |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
438 ;; (goto-char (match-beginning 0)) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
439 ;; (backward-char 2) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
440 ;; (if (not (looking-at "\r\n")) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
441 ;; (insert "\r\n")) |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
442 ;; (re-search-forward "\\.\r\n") |
17493 | 443 (goto-char (match-beginning 0)) |
444 (setq end (point-marker)) | |
445 (pop3-clean-region start end) | |
446 (pop3-munge-message-separator start end) | |
447 (save-excursion | |
448 (set-buffer crashbuf) | |
449 (erase-buffer)) | |
450 (copy-to-buffer crashbuf start end) | |
451 (delete-region start end) | |
452 ))) | |
453 | |
454 (defun pop3-dele (process msg) | |
455 "Mark message-id MSG as deleted." | |
456 (pop3-send-command process (format "DELE %s" msg)) | |
457 (pop3-read-response process)) | |
458 | |
459 (defun pop3-noop (process msg) | |
460 "No-operation." | |
461 (pop3-send-command process "NOOP") | |
462 (pop3-read-response process)) | |
463 | |
464 (defun pop3-last (process) | |
465 "Return highest accessed message-id number for the session." | |
466 (pop3-send-command process "LAST") | |
467 (let ((response (pop3-read-response process t))) | |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
59996
diff
changeset
|
468 (string-to-number (nth 1 (split-string response " "))) |
17493 | 469 )) |
470 | |
471 (defun pop3-rset (process) | |
472 "Remove all delete marks from current maildrop." | |
473 (pop3-send-command process "RSET") | |
474 (pop3-read-response process)) | |
475 | |
476 ;; UPDATE | |
477 | |
478 (defun pop3-quit (process) | |
479 "Close connection to POP3 server. | |
480 Tell server to remove all messages marked as deleted, unlock the maildrop, | |
481 and close the connection." | |
482 (pop3-send-command process "QUIT") | |
483 (pop3-read-response process t) | |
484 (if process | |
485 (save-excursion | |
486 (set-buffer (process-buffer process)) | |
487 (goto-char (point-max)) | |
488 (delete-process process)))) | |
489 | |
490 ;; Summary of POP3 (Post Office Protocol version 3) commands and responses | |
491 | |
492 ;;; AUTHORIZATION STATE | |
493 | |
494 ;; Initial TCP connection | |
495 ;; Arguments: none | |
496 ;; Restrictions: none | |
497 ;; Possible responses: | |
498 ;; +OK [POP3 server ready] | |
499 | |
500 ;; USER name | |
501 ;; Arguments: a server specific user-id (required) | |
502 ;; Restrictions: authorization state [after unsuccessful USER or PASS | |
503 ;; Possible responses: | |
504 ;; +OK [valid user-id] | |
505 ;; -ERR [invalid user-id] | |
506 | |
507 ;; PASS string | |
508 ;; Arguments: a server/user-id specific password (required) | |
509 ;; Restrictions: authorization state, after successful USER | |
510 ;; Possible responses: | |
511 ;; +OK [maildrop locked and ready] | |
512 ;; -ERR [invalid password] | |
513 ;; -ERR [unable to lock maildrop] | |
514 | |
515 ;;; TRANSACTION STATE | |
516 | |
517 ;; STAT | |
518 ;; Arguments: none | |
519 ;; Restrictions: transaction state | |
520 ;; Possible responses: | |
521 ;; +OK nn mm [# of messages, size of maildrop] | |
522 | |
523 ;; LIST [msg] | |
524 ;; Arguments: a message-id (optional) | |
525 ;; Restrictions: transaction state; msg must not be deleted | |
526 ;; Possible responses: | |
527 ;; +OK [scan listing follows] | |
528 ;; -ERR [no such message] | |
529 | |
530 ;; RETR msg | |
531 ;; Arguments: a message-id (required) | |
532 ;; Restrictions: transaction state; msg must not be deleted | |
533 ;; Possible responses: | |
534 ;; +OK [message contents follow] | |
535 ;; -ERR [no such message] | |
536 | |
537 ;; DELE msg | |
538 ;; Arguments: a message-id (required) | |
539 ;; Restrictions: transaction state; msg must not be deleted | |
540 ;; Possible responses: | |
541 ;; +OK [message deleted] | |
542 ;; -ERR [no such message] | |
543 | |
544 ;; NOOP | |
545 ;; Arguments: none | |
546 ;; Restrictions: transaction state | |
547 ;; Possible responses: | |
548 ;; +OK | |
549 | |
550 ;; LAST | |
551 ;; Arguments: none | |
552 ;; Restrictions: transaction state | |
553 ;; Possible responses: | |
554 ;; +OK nn [highest numbered message accessed] | |
555 | |
556 ;; RSET | |
557 ;; Arguments: none | |
558 ;; Restrictions: transaction state | |
559 ;; Possible responses: | |
560 ;; +OK [all delete marks removed] | |
561 | |
562 ;;; UPDATE STATE | |
563 | |
564 ;; QUIT | |
565 ;; Arguments: none | |
566 ;; Restrictions: none | |
567 ;; Possible responses: | |
568 ;; +OK [TCP connection closed] | |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
569 |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
570 (provide 'pop3) |
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
571 |
52401 | 572 ;;; arch-tag: 2facc142-1d74-498e-82af-4659b64cac12 |
26108
08a36c7a0a52
Merge changes from version `1.3s' which we weren't sent.
Dave Love <fx@gnu.org>
parents:
24599
diff
changeset
|
573 ;;; pop3.el ends here |