From 97bb10936825f98186dab06020dc8fd9b66cf0f3 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Wed, 22 Jun 2011 21:24:51 +0200 Subject: [PATCH] (smtpmail-try-auth-methods): If the user has stored a user name, then query for the password first, instead of waiting for SMTP to give an error message and the trying again. --- lisp/ChangeLog | 6 ++++++ lisp/mail/smtpmail.el | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6fb8a993d57..86cf9e06b11 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-06-22 Lars Magne Ingebrigtsen + + * mail/smtpmail.el (smtpmail-try-auth-methods): If the user has + stored a user name, then query for the password first, instead of + waiting for SMTP to give an error message and the trying again. + 2011-06-22 Lawrence Mitchell * net/browse-url.el (browse-url-xdg-open): Use 0, rather than nil diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index b1685067c08..3c9ea9de573 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -477,6 +477,10 @@ The list is in preference order.") (defun smtpmail-try-auth-methods (process supported-extensions host port &optional ask-for-password) + (setq port + (if port + (format "%s" port) + "smtp")) (let* ((mechs (cdr-safe (assoc 'auth supported-extensions))) (mech (car (smtpmail-intersection mechs smtpmail-auth-supported))) (auth-source-creation-prompts @@ -486,9 +490,7 @@ The list is in preference order.") (auth-source-search :max 1 :host host - :port (if port - (format "%s" port) - "smtp") + :port port :require (and ask-for-password '(:user :secret)) :create ask-for-password))) @@ -497,6 +499,20 @@ The list is in preference order.") (save-function (and ask-for-password (plist-get auth-info :save-function))) ret) + (when (and user + (not password)) + ;; The user has stored the user name, but not the password, so + ;; ask for the password, even if we're not forcing that through + ;; `ask-for-password'. + (setq auth-info + (car + (auth-source-search + :max 1 + :host host + :port port + :require '(:user :secret) + :create t)) + password (plist-get auth-info :secret))) (when (functionp password) (setq password (funcall password))) (cond -- 2.39.2