Subject: Re: bug#35682: 27.0.50; Weird failure to authenticate in smtpmail

From: Stefan Monnier <[email-masked]>
Date: Sat, 11 May 2019 09:12:40 -0400

>     Stefan>     (setq send-mail-function #'smtpmail-send-it) (setq
>     Stefan> smtpmail-smtp-service 587) (setq smtpmail-smtp-server
>     Stefan> <mailserver>) (setq smtpmail-smtp-user
>     Stefan> "[email-masked]")
> Iʼd encourage 465 rather than 587, but that might not work for you.

Indeed, 465 doesn't work here.

>     Stefan> I can work around the problem with the patch below, but I
> ENOPATCH (but I can imagine what it looks like)

Duh.  See below.

> Talk to your SMTP admin, they've messed something up. 453 is basically
> 'go away, Iʼm not accepting messages'. 530 is 'go away, you haven't
> authenticated yourself'.

Yet the text they return says pretty much what you describe of 530.

> Iʼm assuming you donʼt have an authinfo entry for this user?

Indeed.

> If I remember correctly, when you do have such an entry (including
> a passwordless one) smtpmail.el will proactively authenticate, rather
> than wait for a rejection. (see smtpmail-try-auth-methods)

Shouldn't smtpmail.el also proactively authenticate when
smtpmail-smtp-user is set?

        Stefan

diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index a79e3db52d..8bb8cb8fad 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -336,7 +336,11 @@ smtpmail-send-it
 	      (if (not (null smtpmail-recipient-address-list))
 		  (when (setq result
 			      (smtpmail-via-smtp
-			       smtpmail-recipient-address-list tembuf))
+			       smtpmail-recipient-address-list tembuf
+                               ;; FIXME: It looks like I need this setting
+                               ;; otherwise my SMTP server signals a 453 error
+                               ;; because I'm not authenticated.
+                               t))      ;ask-for-password
 		    (error "Sending failed: %s" result))
 		(error "Sending failed; no recipients"))
 	    (let* ((file-data