Xiyue Deng <manp...@gmail.com> writes:
> According to the Emacs docs on X-Message-SMTP-Method[1], you can specify > it like > > ,---- > | X-Message-SMTP-Method: smtp smtp.fsf.org 587 other-user > `---- > > Where it "uses ‘other-user’ as the user name when authenticating. This > is handy if you have several SMTP accounts on the same server." I have > several Gmail accounts set up in Gnus and this is what works for me to > let Gmail know which account I'm trying to send from. > > [1] > https://www.gnu.org/software/emacs/manual/html_node/message/Mail-Variables.html Interesting..., thanks for the link! My current configuration, which finally started working (see the parallel thread of this discussion), looks like this: --8<-----------------cut here----------------start--------------->8-- (setq gnus-posting-styles `((".*" (signature ,user-full-name) (address "eg...@protonmail.ch") ("GCC" "nnimap+main:Sent") ("X-Message-SMTP-Method" "smtp 127.0.0.1 1025")) ("nnimap\\+gmail:.*" (address "redac...@gmail.com") ("GCC" "nnimap+gmail:[Gmail]/Sent Mail") ("X-Message-SMTP-Method" "smtp smtp.gmail.com 587")))) (defun my-configure-smtp-stream-type () (cond ((equal user-mail-address "eg...@protonmail.ch") (setq smtpmail-stream-type 'ssl)) ((equal user-mail-address "redac...@gmail.com") (setq smtpmail-stream-type 'starttls)))) (add-hook 'message-send-hook #'my-configure-smtp-stream-type) --8<-----------------cut here----------------end----------------->8-- Here, I don't specify the username in X-Message-SMTP-Method but instead handle it in the (address "...") setting. According to the Posting Styles documentation [1], "address, overriding user-mail-address". I assume this works similarly. However, in my current working version, the key seemed to be correctly setting smtpmail-stream-type, which I configure in the hook. I'm not thrilled with this design, of course, but it works. If you have any suggestions on how to improve it, I’d be happy to hear them. [1] https://www.gnu.org/software/emacs/manual/html_node/gnus/Posting-Styles.html -- Serghei Iakovlev