Subject: 30.1; rmail with two remote mailboxes and both passwords in .authinfo.gpg

From: Roman Rusch <[email-masked]>
Date: Sun, 10 Aug 2025 20:02:29 +0200

Dear Sir or Madam,

I've set up emacs rmail to withdraw the emails from two remote
Mailboxes (with gnu movemail) and store it in one local inbox by
having two entrances in rmail-inbox list like below:

rmail-inbox-list '("pops://XXX"
 		   "pops://YYY")

The password for both accounts are correctly stored in a .authinfo.gpg
file, as described in the Info-page "Auth-source" for Emacs. The two
passwords are different.

The bug is that the command to get the emails always triggers an
"authentication failed" for the second account - whatever the order in
the above list is. But the authentication always works when in
rmail-inbox-list only one account is defined.

It took me a while to figure out that rmail is NOT reading in the
password from the .authinfo.gpg file at all for the second account,
because it already has read in one before and thinks it does not have
to do so anymore.  As a consequence it uses the password of the first
account also for the second one, which causes the "authentication
failed" error.

I believe I've found the reason for the above problem in the file
"rmail.el" -> "defun rmail-get-remote-password". By commenting out the
first "when" expression as shown below I could at least make it work
again for my case:

  ;;(when (not rmail-encoded-remote-password)
    (if (not rmail-remote-password)
        (setq rmail-remote-password
              (let ((found (nth 0 (auth-source-search
                                   :max 1 :user user :host host
                                   :require '(:secret)))))
                (if found
                    (auth-info-password found)
                  (read-passwd (if imap
                                   "IMAP password: "
                                 "POP password: "))))))
    (rmail-set-remote-password rmail-remote-password)
    (setq rmail-remote-password nil);;)
  (rmail-encode-string rmail-encoded-remote-password (emacs-pid))
  )

I like rmail a lot for its simplicity and hope this helps to make it
even better.

Best regards,
Roman