Subject: bug#78996: closed (Re: bug#78996: 29.4; Invalid authinfo credentials when sending mail through SMTP)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 20 Jul 2025 11:50:02 +0000

Your bug report

#78996: 29.4; Invalid authinfo credentials when sending mail through SMTP

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
78996: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78996
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78996: 29.4; Invalid authinfo credentials when sending mail through SMTP
From: Eli Zaretskii <[email-masked]>
To: 8dcc <[email-masked]>
Cc: [email-masked]
Date: Sun, 20 Jul 2025 14:49:48 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: 8dcc <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 20 Jul 2025 12:21:40 +0200
> 
> > You have message-send-hook and message-sent-hook to do this.
> >
> > I don't understand why this is hacky, since your original code was
> > also in a hook.
> 
> I think modifying a global variable permanently from within a hook is
> hacky, and I think saving it in a temporary variable across hooks is
> also a hacky work-around. That's just my opinion.

Understood.

> > Anyway, I think this bug can be closed now?
> 
> Yes. Thank you for your help!

Thanks, done.

Subject: 29.4; Invalid authinfo credentials when sending mail through SMTP
From: 8dcc <[email-masked]>
To: [email-masked]
Date: Fri, 11 Jul 2025 17:58:47 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

I have been trying to write a simple Emacs Lisp function that lets me
select the credentials that are used when sending mail through
`compose-mail' with `message-send-mail-function' set to
`smtpmail-send-it'. I tried many things, including modifying the "From:"
field, and changing `user-mail-address' (both locally and
globally). Although the "From" header does indeed change to the right
value when sending the email, the credentials used when authenticating
with the SMTP server don't change; in the case of Gmail, this "From"
header gets overwritten and a new "X-Google-Original-From" header is
added.

I thought that the email that was used for authentication was the one I
had originally set as `user-mail-address', but it turns out that it
entirely depends on the order of the entries in my '~/authinfo.gpg'
file.

For example, if the contents of the file were:

    machine 127.0.0.1 login my-user port ssh password "****"
    machine smtp.gmail.com login [email-masked] password "****" port 465
    machine smtp.gmail.com login [email-masked] password "****" port 465

Then the credentials of "[email-masked]" would be used, since it's the
first line whose "machine" value matches the value of my
`smtpmail-smtp-server' variable.

Please let me know if you need any more information.

Thank you,
8dcc.