Subject: Re: bug#66602: 29.1; smtpmail-send-it fails to authenticate using auth-sources

From: Jens Östlund <[email-masked]>
Date: Wed, 18 Oct 2023 14:51:27 +0200

Eli Zaretskii <[email-masked]> writes:

>> Date: Wed, 18 Oct 2023 08:17:07 +0200
>> From:  Jens Östlund via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>>
>> When sending an email with 'smtpmail-send-it' the function 'smtpmail-try-auth-methods' fails to find the matching entry. Using 'edebug' I've found that the reason is this piece of code where the 'port' is converted to a string (smtpmail.el.gz:533-536):
>>
>> '(setq port
>> 	(if port
>> 	    (format "%s" port)
>> 	  "smtp"))'
>>
>> When the 'port' is later passed to 'auth-source-search' on line 541 it fails to find any matching entries since ':port' is matched as a number, not a string. If I remove the above piece of code, so that 'port' is never turned into a string, sending the email works as expected. Maybe the best solution is to make 'auth-source-search' match both numeric and string values, at least for the ':port' argument.
>>
>> SMTP session trace:
>>
>> '220 mailrelay6 ESMTP
>> 250-mailrelay6
>> 250-PIPELINING
>> 250-CHUNKING
>> 250-SIZE 104857600
>> 250-AUTH LOGIN PLAIN
>> 250-ENHANCEDSTATUSCODES
>> 250 8BITMIME
>> MAIL FROM:<[email-masked]> SIZE=322
>> 550 5.7.1 [M1] Authentication required (431ff6c7-6d37-11ee-accc-23968f462fbe)
>> QUIT
>> 221 2.0.0 Bye
>>
>> Process smtpmail connection broken by remote peer’
>
> Thanks.
>
> I guess I'm missing something, because I use smtpmail with
> authentication and a specific port all the time without any trouble.
> So maybe show the entry from your ~/.authinfo?
>
> Also, can you point me to the place where you see that port is matched
> as a number?  See also bug#55199, where a similar problem was fixed,
> and the fix should be in Emacs 29.1.  Maybe you have a stale
> auth-sources.elc?

Indeed seem to have been a stale auth-sources.elc file. I recompiled the file and now everything works as expected. Thank you for your quick response, and sorry for taking up your time!

Cheers,

Jens