# HG changeset patch
# User Richard M. Stallman <rms@gnu.org>
# Date 869868504 0
# Node ID 6253a99afd9500bbb64a1736222c742620a5c941
# Parent  35c373c1f92567e5a307d0a05ef45f02670045e0
(rmail-pop-password-error): New variable.
(rmail-insert-inbox-text): If there's an error getting mail from
the POP server, and the error matches rmail-pop-password-error or
we prompted for the POP password, assume that the password is
incorrect and erase it so that the user will be prompted again the
next time he gets mail.

diff -r 35c373c1f925 -r 6253a99afd95 lisp/mail/rmail.el
--- a/lisp/mail/rmail.el	Fri Jul 25 20:51:42 1997 +0000
+++ b/lisp/mail/rmail.el	Fri Jul 25 22:08:24 1997 +0000
@@ -102,6 +102,11 @@
   :type 'boolean
   :group 'rmail-retrieve)
 
+(defvar rmail-pop-password-error "invalid usercode or password"
+  "Regular expression matching incorrect-password POP server error messages.
+If you get an incorrect-password error that this expression does not match,
+please report it with \\[report-emacs-bug].")
+
 (defcustom rmail-preserve-inbox nil
   "*Non-nil if incoming mail should be left in the user's inbox,
 rather than deleted, after it is retrieved."
@@ -1183,7 +1188,7 @@
   (or (memq (file-locked-p buffer-file-name) '(nil t))
       (error "RMAIL file %s is locked"
 	     (file-name-nondirectory buffer-file-name)))
-  (let (file tofile delete-files movemail popmail)
+  (let (file tofile delete-files movemail popmail got-password)
     (while files
       (setq file (file-truename
 		  (expand-file-name (substitute-in-file-name (car files))))
@@ -1222,7 +1227,8 @@
 		 (setq rmail-pop-password
 		       (rmail-read-passwd
 			(format "Password for %s: "
-				(substring file (+ popmail 3))))))
+				(substring file (+ popmail 3))))
+		       got-password t))
 	     (if (eq system-type 'windows-nt)
 		 ;; cannot have "po:" in file name
 		 (setq tofile
@@ -1297,6 +1303,13 @@
 		       (message "movemail: %s"
 				(buffer-substring (point-min)
 						  (point-max)))
+
+		       (if (or got-password
+			       ;; If the error was  for an incorrect password,
+			       ;; arrange to try again to read the password.
+			       (re-search-forward rmail-pop-password-error
+						  nil t))
+			   (setq rmail-pop-password nil))
 		       (sit-for 3)
 		       nil))
 		 (if errors (kill-buffer errors))))))