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