Serghei Iakovlev via "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)" wrote:
> Leo Butler writes: > >>> --8<-----------------cut here----------------start--------------->8-- >>> (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-- >> >> That function/hook is unnecessary. You can use >> `gnus-secondary-select-methods' or use the Server Buffer to configure >> the stream type. >> >> (info "(Gnus) Customizing the IMAP Connection") >> (info "(Gnus) Server Buffer") > > The last thing I would have thought of is configuring SMTP settings > through IMAP connection customization. As I mentioned earlier, I > don't have any issues with reading emails from any of my accounts—the > problem was specifically with sending mail and selecting the correct > value for smtpmail-stream-type. Apologies if I misunderstood your > point, but I did read the info pages you referenced, and I didn't > find anything related to setting up SMTP there. (info "(smtpmail) Authentication") was probably what was meant, but even there, choosing the stream type seems to require such a tweak as yours. But there seems to be a better way; see: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/message.el#n5027 Basically if you name the function as message-send-mail-with-<name>, you should be able to directly call it from X-Message-SMTP-Method. --