From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/12694 Path: main.gmane.org!not-for-mail From: Christian Limpach Newsgroups: gmane.emacs.gnus.general Subject: Re: ideas needed for nnmail-pop3-movemail Date: 25 Oct 1997 04:20:40 +0100 Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035152185 5171 80.91.224.250 (20 Oct 2002 22:16:25 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 22:16:25 +0000 (UTC) Return-Path: Original-Received: from xemacs.org (xemacs.cs.uiuc.edu [128.174.252.16]) by altair.xemacs.org (8.8.7/8.8.7) with ESMTP id VAA18486 for ; Fri, 24 Oct 1997 21:38:51 -0700 Original-Received: from ifi.uio.no (ifi.uio.no [129.240.64.2]) by xemacs.org (8.8.5/8.8.5) with ESMTP id XAA21908 for ; Fri, 24 Oct 1997 23:40:26 -0500 (CDT) Original-Received: from claymore.vcinet.com (claymore.vcinet.com [208.205.12.23]) by ifi.uio.no (8.8.7/8.8.7/ifi0.2) with SMTP id FAA08019 for ; Sat, 25 Oct 1997 05:25:10 +0200 (MET DST) Original-Received: (qmail 17296 invoked by uid 504); 25 Oct 1997 03:25:06 -0000 Original-Received: (qmail 17293 invoked from network); 25 Oct 1997 03:25:05 -0000 Original-Received: from nice.ethz.ch (129.132.71.53) by claymore.vcinet.com with SMTP; 25 Oct 1997 03:25:05 -0000 Original-Received: (from uucp@localhost) by nice.ethz.ch (8.8.7/8.8.7) id FAA21139 for gnus.org!ding; Sat, 25 Oct 1997 05:25:00 +0200 (MET DST) Original-Received: (from chris@localhost) by delight.pin.lu (8.7.6/8.7.3) id FAA03877; Sat, 25 Oct 1997 05:20:42 +0200 (MET DST) Original-To: "(ding)" In-Reply-To: Stainless Steel Rat's message of "24 Oct 1997 22:25:14 -0400" Original-Lines: 252 X-Mailer: Gnus v5.4.59/Emacs 19.34 Xref: main.gmane.org gmane.emacs.gnus.general:12694 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:12694 Stainless Steel Rat writes: > Lars> '((file :type mbox :location "/usr/spool/mail/larsi") > Lars> (pop :host "somewhere" :function pop3-movemail)) > > Hmm... if that comes about then no, we do not. The mailbox iteration will > be handled directly within nnmail. Good deal. the only thing that will be needed in pop3 is a way to save passwords for different servers. Since the user gets prompted for a password in pop3, pop3 is also where the password should be saved when it was used succesfully. I have used this for quite some time now together with a setup which decodes pop-server specifications similar to the ones used by vm. Below is what I have been using for some time now. christian diffs are against 5.4.59... (require 'pop3) (defun cl/nnmail-pop3-movemail (inbox crashbox) "Function to move mail from INBOX on a pop3 server to file CRASHBOX." (let* ((source (substring inbox (match-end (string-match "^po:" inbox)))) (source-list (cl/parse source "\\([^:]+\\):?"))) (if (> (length source-list) 1) (let ((pop3-maildrop (nth 0 source-list)) (pop3-mailhost (nth 1 source-list)) (pop3-port (if (or (null (nth 2 source-list)) (equal (nth 2 source-list) "*") (not (string-match "^[0-9]+$" (nth 2 source-list)))) pop3-port (string-to-int (nth 2 source-list)))) (pop3-authentication-scheme (if (or (null (nth 3 source-list)) (equal (nth 3 source-list) "*")) pop3-authentication-scheme (intern (nth 3 source-list))))) ;; carp if parts are missing (if (null pop3-maildrop) (error "No user in POP maildrop specification, \"%s\"" source)) (if (null pop3-mailhost) (error "No host in POP maildrop specification, \"%s\"" source)) (condition-case nil (pop3-movemail crashbox) (error nil))) (pop3-movemail crashbox)))) (custom-set-variables '(nnmail-spool-file (quote ("po:chris-pop:nice.ethz.ch" "/usr/spool/mail/chris" "~/Mail/spool/New"))) '(nnmail-pop-password-required nil) '(nnmail-popmail-program (quote cl/nnmail-pop3-movemail)) ) *** nnmail.el 1997/06/21 19:10:05 1.1 --- nnmail.el 1997/06/21 20:34:19 *************** *** 238,243 **** --- 238,255 ---- :group 'nnmail-retrieve :type 'string) + (defcustom nnmail-popmail-program nil + "*A command to be executed to move mail from a pop3 server inbox. + The default is nil. If nil, nnmail-movemail-program is also used with + pop3 server inboxes. + + This can also be a function. In that case, the function will be + called with two parameters -- the name of the INBOX file, and the file + to be moved to." + :group 'nnmail-files + :group 'nnmail-retrieve + :type 'string) + (defcustom nnmail-pop-password-required nil "*Non-nil if a password is required when reading mail using POP." :group 'nnmail-retrieve *************** *** 547,555 **** (when (and (file-exists-p nnmail-crash-box) (zerop (nnheader-file-size (file-truename nnmail-crash-box)))) (delete-file nnmail-crash-box)) ! (let ((tofile (file-truename (expand-file-name nnmail-crash-box))) ! (popmail (string-match "^po:" inbox)) ! movemail errors result) (unless popmail (setq inbox (file-truename (expand-file-name inbox))) (setq movemail t) --- 559,570 ---- (when (and (file-exists-p nnmail-crash-box) (zerop (nnheader-file-size (file-truename nnmail-crash-box)))) (delete-file nnmail-crash-box)) ! (let* ((tofile (file-truename (expand-file-name nnmail-crash-box))) ! (popmail (string-match "^po:" inbox)) ! (movemail-program (if (and popmail nnmail-popmail-program) ! nnmail-popmail-program ! nnmail-movemail-program)) ! movemail errors result) (unless popmail (setq inbox (file-truename (expand-file-name inbox))) (setq movemail t) *************** *** 596,605 **** (setq errors (generate-new-buffer " *nnmail loss*")) (buffer-disable-undo errors) (let ((default-directory "/")) ! (if (nnheader-functionp nnmail-movemail-program) (condition-case err (progn ! (funcall nnmail-movemail-program inbox tofile) (setq result 0)) (error (save-excursion --- 611,620 ---- (setq errors (generate-new-buffer " *nnmail loss*")) (buffer-disable-undo errors) (let ((default-directory "/")) ! (if (nnheader-functionp movemail-program) (condition-case err (progn ! (funcall movemail-program inbox tofile) (setq result 0)) (error (save-excursion *************** *** 612,618 **** (append (list (expand-file-name ! nnmail-movemail-program exec-directory) nil errors nil inbox tofile) (when nnmail-internal-password (list nnmail-internal-password))))))) --- 627,633 ---- (append (list (expand-file-name ! movemail-program exec-directory) nil errors nil inbox tofile) (when nnmail-internal-password (list nnmail-internal-password))))))) *************** *** 647,653 **** (buffer-string) result)) (error "%s" (buffer-string))) (setq tofile nil))))))) ! (message "Getting mail from %s...done" inbox) (and errors (buffer-name errors) (kill-buffer errors)) --- 662,668 ---- (buffer-string) result)) (error "%s" (buffer-string))) (setq tofile nil))))))) ! (message "Getting mail from %s...done" (if popmail "the post office" inbox)) (and errors (buffer-name errors) (kill-buffer errors)) *** pop3.el 1997/06/21 18:59:51 1.1 --- pop3.el 1997/06/21 20:56:50 *************** *** 50,55 **** --- 50,57 ---- "*Non-nil if a password is required when connecting to POP server.") (defvar pop3-password nil "*Password to use when connecting to POP server.") + (defvar pop3-save-password t + "*Save password after first successful use.") (defvar pop3-authentication-scheme 'pass "*POP3 authentication scheme. *************** *** 249,270 **** (defun pop3-pass (process) "Send authentication information to the server." ! (let ((pass pop3-password)) (if (and pop3-password-required (not pass)) (setq pass ! (pop3-read-passwd (format "Password for %s: " pop3-maildrop)))) (if pass (progn (pop3-send-command process (format "PASS %s" pass)) (let ((response (pop3-read-response process t))) (if (not (and response (string-match "+OK" response))) ! (pop3-quit process))))) )) (defun pop3-apop (process user) "Send alternate authentication information to the server." (if (not (fboundp 'md5)) (autoload 'md5 "md5")) ! (let ((pass pop3-password)) (if (and pop3-password-required (not pass)) (setq pass (pop3-read-passwd (format "Password for %s: " pop3-maildrop)))) --- 251,277 ---- (defun pop3-pass (process) "Send authentication information to the server." ! (let ((pass (cdr (assoc pop3-mailhost pop3-password)))) (if (and pop3-password-required (not pass)) (setq pass ! (pop3-read-passwd (format "Password for %s@%s: " ! pop3-maildrop pop3-mailhost)))) (if pass (progn (pop3-send-command process (format "PASS %s" pass)) (let ((response (pop3-read-response process t))) (if (not (and response (string-match "+OK" response))) ! (pop3-quit process) ! (if pop3-save-password ! (or (assoc pop3-mailhost pop3-password) ! (setq pop3-password (append pop3-password ! (list (cons pop3-mailhost pass)))))))))) )) (defun pop3-apop (process user) "Send alternate authentication information to the server." (if (not (fboundp 'md5)) (autoload 'md5 "md5")) ! (let ((pass (cdr (assoc pop3-mailhost pop3-password)))) (if (and pop3-password-required (not pass)) (setq pass (pop3-read-passwd (format "Password for %s: " pop3-maildrop)))) *************** *** 273,279 **** (pop3-send-command process (format "APOP %s %s" user hash)) (let ((response (pop3-read-response process t))) (if (not (and response (string-match "+OK" response))) ! (pop3-quit process))))) )) ;; TRANSACTION STATE --- 280,290 ---- (pop3-send-command process (format "APOP %s %s" user hash)) (let ((response (pop3-read-response process t))) (if (not (and response (string-match "+OK" response))) ! (pop3-quit process) ! (if pop3-save-password ! (or (assoc pop3-mailhost pop3-password) ! (setq pop3-password (append pop3-password ! (list (cons pop3-mailhost pass)))))))))) )) ;; TRANSACTION STATE