Gnus development mailing list
 help / color / mirror / Atom feed
From: Christian Limpach <Christian.Limpach@Nice.CH>
Subject: Re: ideas needed for nnmail-pop3-movemail
Date: 25 Oct 1997 04:20:40 +0100	[thread overview]
Message-ID: <x790vimstz.fsf@delight.pin.lu> (raw)
In-Reply-To: Stainless Steel Rat's message of "24 Oct 1997 22:25:14 -0400"

Stainless Steel Rat <ratinox@peorth.gweep.net> 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


  parent reply	other threads:[~1997-10-25  3:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <x74t6c2gbt.fsf@peorth.gweep.net>
1997-10-24 22:36 ` Lars Magne Ingebrigtsen
     [not found]   ` <x7bu0elgtx.fsf@peorth.gweep.net>
1997-10-25  3:20     ` Christian Limpach [this message]
     [not found]       ` <x7lnzhm9dk.fsf@peorth.gweep.net>
1997-10-26 18:05         ` Christian Limpach
     [not found]           ` <x73elo467n.fsf@peorth.gweep.net>
1997-10-27 13:47             ` Christian Limpach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=x790vimstz.fsf@delight.pin.lu \
    --to=christian.limpach@nice.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).