diff options
| -rw-r--r-- | lisp/mail/smtpmail.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index dcec0b1d9e9..dc3293fb2f4 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -639,11 +639,21 @@ USER and PASSWORD should be non-nil." | |||
| 639 | 639 | ||
| 640 | (cl-defmethod smtpmail-try-auth-method | 640 | (cl-defmethod smtpmail-try-auth-method |
| 641 | (process (_mech (eql 'xoauth2)) user password) | 641 | (process (_mech (eql 'xoauth2)) user password) |
| 642 | (smtpmail-command-or-throw | 642 | (let ((ret (smtpmail-command-or-throw |
| 643 | process | 643 | process |
| 644 | (concat "AUTH XOAUTH2 " | 644 | (concat "AUTH XOAUTH2 " |
| 645 | (base64-encode-string | 645 | (base64-encode-string |
| 646 | (concat "user=" user "\1auth=Bearer " password "\1\1") t)))) | 646 | (concat "user=" user "\1auth=Bearer " password "\1\1") |
| 647 | t))))) | ||
| 648 | (if (eq (car ret) 334) | ||
| 649 | ;; When a server returns 334 server challenge, it usually means | ||
| 650 | ;; the credentials it received were wrong (e.g. was an actual | ||
| 651 | ;; password instead of an access token). In such a case, we | ||
| 652 | ;; should return a string with 535 to indicate a failure so that | ||
| 653 | ;; smtpmail will try other authentication mechanisms. See also | ||
| 654 | ;; https://debbugs.gnu.org/78366. | ||
| 655 | (throw 'done "535 5.7.8 Authentication credentials invalid") | ||
| 656 | ret))) | ||
| 647 | 657 | ||
| 648 | (defun smtpmail-response-code (string) | 658 | (defun smtpmail-response-code (string) |
| 649 | (when string | 659 | (when string |