1 ;; pop3-fma.el.el --- POP3 for Multiple Account for Gnus.
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc. , Tatsuya Ichikawa
3 ;; Author: Tatsuya Ichikawa <t-ichi@po.shiojiri.ne.jp>
5 ;; Keywords: mail , gnus , pop3
8 ;; Keiichi Suzuki <kei-suzu@mail.wbs.or.jp>
9 ;; Katsumi Yamaoka <yamaoka@jpl.org>
11 ;; This file is not part of GNU Emacs.
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)
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.
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.
33 ;; add your .emacs following codes.
35 ;; (autoload 'pop3-fma-set-pop3-password "pop3-fma")
36 ;; (add-hook 'gnus-load-hook 'pop3-fma-set-pop3-password)
37 ;; (setq pop3-fma-spool-file-alist
39 ;; "po:username0@mailhost0.your.domain0"
40 ;; "po:username1@mailhost1.your.domain1"
47 ;; pop3-fma-spool-file-alist ... Spool file alist of POP3 protocol
48 ;; pop3-fma-movemail-type ... Type of movemail program.
52 ;; pop3-fma-movemail-arguments ... List of options of movemail program.
59 (unless (and (condition-case ()
65 (defmacro defgroup (&rest args))
66 (defmacro defcustom (symbol value &optional doc &rest args)
67 (` (defvar (, symbol) (, value) (, doc))))
70 (defgroup pop3-fma nil
71 "Multile POP3 account utility for Gnus."
76 (defconst pop3-fma-version-number "0.12")
77 (defconst pop3-fma-codename
78 ;;; "Feel the wind" ; 0.10
79 ;; "My home town" ; 0.11
81 ;; "Before generation of Love" ; 0.xx
82 ;; "Lonely Christmas eve" ; 0.xx
83 ;; "Rock'n Roll city" ; 0.xx
85 ;; "Midnight blue train" ; 0.xx
88 ;; "Blood line" ; 0.xx
90 ;; "Goodbye Game" ; 0.xx
92 (defconst pop3-fma-version (format "Multiple POP3 account utiliy for Gnus v%s - \"%s\""
93 pop3-fma-version-number
96 (defcustom pop3-fma-spool-file-alist nil
97 "*Spoolfile to get mail using pop3 protocol.
98 You should specify this variable like
100 \"po:user1@mailhost1\"
101 \"po:user2@mailhost2\"
106 (defcustom pop3-fma-movemail-type 'lisp
107 "*Type of movemail program.
108 Lisp means `nnmail-movemail-program' is lisp function.
109 Exe means `nnmail-movemail-program' is external program.
110 Please do not use exe if you do not use Meadow."
112 :type '(choice (const lisp)
115 (defcustom pop3-fma-movemail-arguments '("-pf")
116 "*Options for movemail."
118 :type '(repeat (string :tag "Argument")))
120 ;;; Internal variables.
121 (defvar pop3-fma-password nil
122 "*POP3 password , user , mailhost information for Gnus.")
124 (defvar pop3-fma-movemail-program "movemail.exe"
125 "*External program name your movemail.
126 Please do not set this valiable non-nil if you do not use Meadow.")
128 ;; Temporary variable
132 (defvar pop3-fma-movemail-options pop3-fma-movemail-arguments)
134 (defun pop3-fma-init-hooks ()
135 (add-hook 'message-send-hook 'pop3-fma-message-add-header))
137 (eval-after-load "message"
138 '(pop3-fma-init-hooks))
141 ;; Gnus POP3 additional utility...
143 (defun pop3-fma-movemail (inbox crashbox)
144 "Function to move mail from INBOX on a pop3 server to file CRASHBOX."
146 (substring inbox (match-end (string-match "^po:" inbox))
147 (- (match-end (string-match "^.*@" inbox)) 1)))
149 (substring inbox (match-end (string-match "^.*@" inbox)))))
151 (pop3-fma-read-passwd pop3-mailhost)))
152 (message "Checking new mail user %s at %s..." pop3-maildrop pop3-mailhost)
153 (if (and (eq system-type 'windows-nt)
154 (eq pop3-fma-movemail-type 'exe))
156 (setenv "MAILHOST" pop3-mailhost)
157 (if (and (not (memq pop3-password pop3-fma-movemail-arguments))
158 (not (memq (concat "po:" pop3-maildrop) pop3-fma-movemail-arguments)))
160 (setq pop3-fma-movemail-arguments nil)
161 (setq pop3-fma-movemail-arguments
162 (append pop3-fma-movemail-options
164 (concat "po:" pop3-maildrop)
167 (apply 'call-process (concat
169 pop3-fma-movemail-program)
171 pop3-fma-movemail-arguments))
172 (pop3-movemail crashbox)))))
175 (defun pop3-fma-read-passwd (mailhost)
176 (setq passwd (nth 2 (assoc mailhost pop3-fma-password)))
179 (setq pop3-read-passwd 'pop3-fma-read-passwd)
181 ;; Set multiple pop3 server's password
182 (defun pop3-fma-store-password (passwd)
184 (list (pop3-fma-read-noecho
185 (format "POP Password for %s at %s: " pop3-maildrop pop3-mailhost) t)))
186 (if (not (assoc pop3-mailhost pop3-fma-password))
187 (setq pop3-fma-password
188 (append pop3-fma-password
194 (setcar (cdr (cdr (assoc pop3-mailhost pop3-fma-password)))
196 (message "POP password registered.")
200 (defun pop3-fma-set-pop3-password()
205 (substring x (match-end (string-match "^po:" x))
206 (- (match-end (string-match "^.*@" x)) 1)))
208 (substring x (match-end (string-match "^.*@" x)))))
209 (call-interactively 'pop3-fma-store-password)))
210 pop3-fma-spool-file-alist)
211 (setq nnmail-movemail-program 'pop3-fma-movemail)
212 (setq nnmail-spool-file pop3-fma-spool-file-alist))
214 (defun pop3-fma-read-noecho (prompt &optional stars)
215 "Read a single line of text from user without echoing, and return it.
220 (cursor-in-echo-area t)
221 (log-message-max-size 0)
222 message-log-max done msg truncate)
224 (if (or (not stars) (string-equal "" ans))
226 (setq msg (concat prompt (make-string (length ans) ?*)))
228 (1+ (- (length msg) (window-width (minibuffer-window)))))
230 (setq msg (concat "$" (substring msg (1+ truncate))))))
232 (setq c (read-char-exclusive))
236 ((or (= c ?\r) (= c ?\n) (= c ?\e))
240 ((and (/= c ?\b) (/= c ?\177))
241 (setq ans (concat ans (char-to-string c))))
243 (setq ans (substring ans 0 -1)))))
253 (defun pop3-fma-message-add-header ()
255 (pop3-fma-add-custom-header "X-Ya-Pop3:" pop3-fma-version)))
258 ;; Add your custom header.
260 (defun pop3-fma-add-custom-header (header string)
262 (progn (goto-char (point-min))
264 (concat "^" (regexp-quote mail-header-separator) "\n"))
266 (goto-char (point-min))
267 (or (re-search-forward (concat "^" header) delimline t)
269 (goto-char delimline)
272 (setq hdr (concat header " "))
273 (setq str (concat hdr string))
274 (setq hdr (concat str "\n"))
275 (insert-string hdr)))))
279 ;; pop3-fma.el ends here.