Björn Bidar <bjorn.bi...@thaodan.de> writes: Hi Björn,
>> (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")))) >> >> (setq message-send-mail-function 'message-smtpmail-send-it) > > This setting is redundant. Message-mode will use the right function > based on the variable below. > >> (setq send-mail-function #'smtpmail-send-it) >> >> (setq smtpmail-debug-info t) >> (setq smtpmail-stream-type 'ssl) I think I've tried about a dozen different combinations before finding a working setup. I also realized I had a typo and was using the wrong port (578 instead of the correct 587). Additionally, I found that setting smtpmail-stream-type to either 'ssl or nil also caused connection errors. It seems like I’ve finally got it working as expected (yay!). Here’s the current version of my relevant code that made Gnus do what I need: --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")))) (setq message-send-mail-function 'message-smtpmail-send-it) (setq send-mail-function #'smtpmail-send-it) (defun my-configure-smtp-stream-type () "Configure the SMTP stream type based on the current user email address." (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-- I'm not entirely satisfied with the design, but at least it works for now. I'd like to think more about it and would love to hear any feedback on this approach; it feels like it could be more elegant. > I would also set smtpmail-servers-requiring-authorization like below so > smtpmail doesn't try to send mail without logging in first. > > (setopt smtpmail-servers-requiring-authorization ".*") > > If you use Emacs 28 or older use setq instead. Thanks for pointing out the `smtpmail-servers-requiring-authorization' setting. That probable makes sense for ensuring that authentication is always enforced when sending mail. But right now it works w/o touching this setting. > You can find my setup for Gnus-alias below: > https://github.com/Thaodan/emacs.d/blob/master/init.org#gnus Thanks for the link to your configuration — I'll definitely take a closer look at it. -- Serghei Iakovlev