Subject: Re: bug#57373: 28.1; authinfo keyword smtp-auth does not work

From: John Kehayias <[email-masked]>
Date: Wed, 24 Aug 2022 15:20:48 +0000

Hello Robert,

Thanks for such a quick response and fix! Let me just add my use case being that some SMTP servers I use have different authentication methods, but will try and fail with the others. I could work around this by modifying the ordering in smtpmail-auth-supported, at least for my current sent of servers. Anyway, was happy to see this feature for exactly this reason.

On Wed, Aug 24, 2022 at 11:30 AM, Robert Pluim wrote:

>>>>>> On Tue, 23 Aug 2022 22:01:10 +0000, John Kehayias via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <[email-masked]> said:
>
>     John> I believe the problem is that in smtpmail-try-auth-methods
>     John> the smtp-auth keyword is read in by auth-source-search as a
>     John> string, while the call to smtpmail-try-auth-method that uses
>     John> it all match with eql, eg. as (eql 'plain).
>
> Yep.
>
>     John> I have tried different ways to get the smtp-auth value read
>     John> differently in my authinfo, to no avail. Looking back at the
>     John> devel mailing list, there was some confusion that this
>     John> feature needed plstore, but in the end did not:
>     John> <https://lists.gnu.org/archive/html/emacs-devel/2020-09/msg00002.html>
>     John> I can confirm that reading the authinfo does provide the
>     John> smtp-auth keyword, it just won't match any method to call.
>
>     John> Perhaps there is a different format for specifying smtp-auth that I didn't find?
>
> auth-source search always returns a plist containg strings as the key
> values. Does the following work for you

Understood, just wanted to be sure I wasn't missing something obvious.

>
> diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
> index c2f8f27377..8573532eac 100644
> --- a/lisp/mail/smtpmail.el
> +++ b/lisp/mail/smtpmail.el
> @@ -577,7 +577,7 @@ smtpmail-try-auth-methods
>                      (stringp result))
>            (setq result (catch 'done
>  		         (smtpmail-try-auth-method
> -                          process (pop mechs) user password))))
> +                          process (intern-soft (pop mechs)) user password))))
>          ;; A string result is an error.
>          (if (stringp result)
>              (progn
>

Yes that works for me! Note that I am not on Emacs 29, nor my Guix machine where I could easily rebuild with a patch, so I just did a local redefinition of smtpmail-try-auth-methods with (intern-soft mech) in the call to smtpmail-try-auth-method. So I didn't backport the full changes to that function I see. I can certainly try that later, but wanted to a quick check. I was able to send mail with smtp-auth specified in my authinfo.

Thanks!
John