Gnus development mailing list
 help / color / mirror / Atom feed
* Re: ideas needed for nnmail-pop3-movemail
       [not found] <x74t6c2gbt.fsf@peorth.gweep.net>
@ 1997-10-24 22:36 ` Lars Magne Ingebrigtsen
       [not found]   ` <x7bu0elgtx.fsf@peorth.gweep.net>
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 1997-10-24 22:36 UTC (permalink / raw)


Stainless Steel Rat <ratinox@peorth.gweep.net> writes:

> The one grating "flaw" in (nnmail-)pop3-movemail is that it cannot handle
> multiple sources for incoming mail.  Getting it to understand multiple POP
> mailboxes is accomplished easilly enough; just loop around an alist.

But do we need this?  I think pop3-movemail works fine as it does
now.  In the future, people'll specify the maildrops with something
like:

'((file :type mbox :location "/usr/spool/mail/larsi")
  (pop :host "somewhere" :function pop3-movemail))

(and so on), which means that pop3-movemail won't have to worry about
these things.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ideas needed for nnmail-pop3-movemail
       [not found]   ` <x7bu0elgtx.fsf@peorth.gweep.net>
@ 1997-10-25  3:20     ` Christian Limpach
       [not found]       ` <x7lnzhm9dk.fsf@peorth.gweep.net>
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Limpach @ 1997-10-25  3:20 UTC (permalink / raw)


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ideas needed for nnmail-pop3-movemail
       [not found]       ` <x7lnzhm9dk.fsf@peorth.gweep.net>
@ 1997-10-26 18:05         ` Christian Limpach
       [not found]           ` <x73elo467n.fsf@peorth.gweep.net>
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Limpach @ 1997-10-26 18:05 UTC (permalink / raw)


Stainless Steel Rat <ratinox@peorth.gweep.net> writes:

> Well, if iteration is handled by nnmail through an alist of mailboxes, then
> nnmail properly should also maintain cache of passwords, either in the same
> alist or a parallel alist, assuming that password caching is enabled (which
> by default it should not).  Within the let form that temporarilly binds
> pop3-maildrop and pop3-mailhost, pop3-password is bound to the cached
> password for the mailhost/maildrop or nil.  Then pop3-movemail is called
> within that let form, and everything just works.

If it is so, then the code which asks for passwords should be removed
from pop3 altogether.  Otherwise there will be two routines which
query for pop3 passwords and this is bad: if the user doesn't enter a
password at the first query (like to skip that pop server) pop3.el
will ask again (current API: no password = ask, right ?).

Also nnmail will not know wheter to save the password or not, as
pop3.el doesn't report why it failed.  Another advantage of pop3.el
handling the password caching is that there could be multiple clients
(gnus, vm) and the user would still only have to enter the password
once.  And finally I prefer to trust pop3.el with my password (after I
have seen the code) than some client.

If you look at my code, you will see, that I have indeed used a let
form to bind all the pop3 variables.  I had first added the parsing of
the pop-server specification to pop3.el, but then I decided that it
would be better to make as few changes to pop3.el as possible.  The
result was that I could move everything out of pop3.el except for
password caching.

What I don't like about my implementation is that it doesn't allow a
single host to be used several times with different
users/ports/... but this can be changed easily by extending the key
used to lookup the password in the alist.

    christian


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ideas needed for nnmail-pop3-movemail
       [not found]           ` <x73elo467n.fsf@peorth.gweep.net>
@ 1997-10-27 13:47             ` Christian Limpach
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Limpach @ 1997-10-27 13:47 UTC (permalink / raw)


> CL> If it is so, then the code which asks for passwords should be removed
> CL> from pop3 altogether.
> 
> No, it shouldn't, because it is part of the basic POP3 specification.  To
> wit, in order to be a complete API it needs to be able to submit
> authentication information to the POP server.

It needs to be able to submit authentification information to the POP
server, but it doesn't have to interactively query the user for that
information.  It would still be a complete API if you removed the
interactive query function.  There's no interactive query function for
host, user, port, whatever in pop3.el and you still consider it to be
complete, so why would there be an interactive query function for
authentification information ?

I think you should move the interactive query function out of
pop3-pass (and pop3-apop) into pop3-movemail.

I can agree with the rest of what you wrote, i.e. pop3-movemail is not
to be used for anything serious and gnus should have a
nnmail-pop3-movemail function which uses the pop3 API directly.

    christian


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-27 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <x74t6c2gbt.fsf@peorth.gweep.net>
1997-10-24 22:36 ` ideas needed for nnmail-pop3-movemail Lars Magne Ingebrigtsen
     [not found]   ` <x7bu0elgtx.fsf@peorth.gweep.net>
1997-10-25  3:20     ` Christian Limpach
     [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

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).