[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3d7a832092: Make smtpmail try all auth methods
From: |
Lars Ingebrigtsen |
Subject: |
master 3d7a832092: Make smtpmail try all auth methods |
Date: |
Wed, 13 Jul 2022 08:35:06 -0400 (EDT) |
branch: master
commit 3d7a8320928a186bd567ff880ccf0fa872b969d1
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make smtpmail try all auth methods
* lisp/mail/smtpmail.el (smtpmail-try-auth-methods): Try all valid
methods, even if one fails (bug#48562).
---
lisp/mail/smtpmail.el | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 8cba2b14e1..fcb072d5d0 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -550,7 +550,6 @@ for `smtpmail-try-auth-method'.")
:require (and ask-for-password
'(:user :secret))
:create ask-for-password)))
- (mech (or (plist-get auth-info :smtp-auth) (car mechs)))
(user (plist-get auth-info :user))
(password (auth-info-password auth-info))
(save-function (and ask-for-password
@@ -570,18 +569,26 @@ for `smtpmail-try-auth-method'.")
:require '(:user :secret)
:create t))
password (auth-info-password auth-info)))
- (let ((result (catch 'done
- (if (and mech user password)
- (smtpmail-try-auth-method process mech user password)
- ;; No mechanism, or no credentials.
- mech))))
- (if (stringp result)
- (progn
- (auth-source-forget+ :host host :port port)
- (throw 'done result))
- (when save-function
- (funcall save-function))
- result))))
+ (let ((mechs (or (ensure-list (plist-get auth-info :smtp-auth))
+ mechs))
+ (result ""))
+ (when (and mechs user password)
+ (while (and mechs
+ (stringp result))
+ (setq result (catch 'done
+ (smtpmail-try-auth-method
+ process (pop mechs) user password))))
+ ;; A string result is an error.
+ (if (stringp result)
+ (progn
+ ;; All methods failed.
+ ;; Forget the credentials.
+ (auth-source-forget+ :host host :port port)
+ (throw 'done result))
+ ;; Success.
+ (when save-function
+ (funcall save-function))
+ result)))))
(cl-defgeneric smtpmail-try-auth-method (_process mech _user _password)
"Perform authentication of type MECH for USER with PASSWORD.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3d7a832092: Make smtpmail try all auth methods,
Lars Ingebrigtsen <=