James Thomas <jim...@gmx.net> writes:

> 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.


So, essentially, you’re suggesting implementing two functions like:

--8<-----------------cut here----------------start--------------->8--
(defun message-send-mail-with-protonmail ())
(defun message-send-mail-with-gmail ())
--8<-----------------cut here----------------end----------------->8--

and then specifying them in `gnus-posting-styles as':

--8<-----------------cut here----------------start--------------->8--
("X-Message-SMTP-Method" "protonmail 127.0.0.1 1025")
("X-Message-SMTP-Method" "gmail smtp.gmail.com 587")
--8<-----------------cut here----------------end----------------->8--

Did I understand you correctly? If that’s what you meant, I think
I’ll pass on this approach. The small hook I’ve implemented, which
has now been simplified further, seems like the most concise option
for my needs:

--8<-----------------cut here----------------start--------------->8--
(defun set-smtp-stream-type-by-domain ()
  (setq smtpmail-stream-type
        (pcase (cadr (split-string user-mail-address "@"))
          ("gmail.com" 'starttls)
          (_ 'ssl))))

(add-hook 'message-send-hook #'set-smtp-stream-type-by-domain)
--8<-----------------cut here----------------end----------------->8--

Thanks for the suggestion, though!

-- 
Serghei Iakovlev


  • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
    • ... Leo Butler
      • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
        • ... Xiyue Deng
          • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
        • ... Björn Bidar
        • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
          • ... Leo Butler
            • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
              • ... James Thomas
                • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
                • ... James Thomas
                • ... James Thomas
                • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
                • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)
                • ... Robert Pluim
                • ... Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader (in English)

Reply via email to