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

>> Need not be that complex, AFAICT. The method could simply be something
>> like "starttls 127.0.0.1 1025" where the only thing you would do is
>> let-bind the stream type and call the default.
>
> Well, I was wrong about this part: 'method' ought to be dynamically
> bound for just that block in the code, for this to be possible.

I need to pay more attention to the provider’s documentation and the
source code of the packages I use, rather than blindly copying
configurations from www.emacswiki.org.  It turned out to be simpler
than I thought.  My eye caught this fragment in the
`message-multi-smtp-send-mail' [1] function:

--8<-----------------cut here----------------start--------------->8--
(smtpmail-stream-type (if (= port 465)
                          'tls
                        smtpmail-stream-type))
--8<-----------------cut here----------------end----------------->8--

Then I just changed the port from 587 to 465 as follows:

--8<-----------------cut here----------------start--------------->8--
("X-Message-SMTP-Method" "smtp smtp.gmail.com 465")
--8<-----------------cut here----------------end----------------->8--

and everything started working!  I double-checked Google’s help
center, and sure enough, they offer two ports — 465 and 587 — and
depending on the port, they expect either TLS or SSL.

So, as you can guess, I completely removed my hook, and my code now
looks much cleaner:

--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")
         ;; For SSL 465, enter use, for TLS, use 587
         ("X-Message-SMTP-Method" "smtp smtp.gmail.com 465"))))

(setq smtpmail-servers-requiring-authorization ".*")
(setq message-send-mail-function #'message-send-mail-with-sendmail)
(setq send-mail-function #'smtpmail-send-it)

;; Will be redefined in `message-multi-smtp-send-mail' later.
(setq-default smtpmail-stream-type 'ssl)
--8<-----------------cut here----------------end----------------->8--

Thanks for nudging me to dig deeper into this!

[1] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/gnus/message.el#n5027

-- 
Serghei Iakovlev


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