Serghei Iakovlev via "Announcements and discussions for GNUS, the GNU
Emacs Usenet newsreader (in English)" <[email protected]>
writes:
> Hi Leo,
>
> I think I’ve already tried something similar to what you’re
> suggesting. I even experimented with a specialized hook. Here’s a
> cleaned-up version of my current setup:
>
> --8<-------------------------- separator ------------------------>8--
> (setq gnus-posting-styles
> `((".*"
> (signature ,user-full-name)
> (address "[email protected]")
> ("GCC" "nnimap+main:Sent")
> ("X-Message-SMTP-Method" "smtp 127.0.0.1 1025"))
> ("nnimap\\+gmail:.*"
> (address "[email protected]")
> ("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 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.
> ;; Disabled in global scope
> ;; (setq smtpmail-default-smtp-server "127.0.0.1")
> ;; (setq smtpmail-smtp-service 1025)
>
> (defun set-mail-transport ()
> (cond ((equal user-mail-address "[email protected]")
> (message "=== sending via proton ===")
> (setq smtpmail-smtp-server "127.0.0.1")
> (setq smtpmail-smtp-service 1025))
> ((equal user-mail-address "[email protected]")
> (message "=== sending via gmail ===")
> (setq smtpmail-smtp-server "smtp.gmail.com")
> (setq smtpmail-smtp-service 587))))
These are redundant and likely break your posting style.
If you don't like posting styles you can also look into gnus-alias.
You can find my setup for Gnus-alias below:
https://github.com/Thaodan/emacs.d/blob/master/init.org#gnus
> (add-hook 'message-send-hook #'set-mail-transport)
> --8<-------------------------- separator ------------------------>8--
>
> Sending via ProtonMail works perfectly fine, but when I try to send
> through Gmail, it just hangs for a long time, and eventually, I get
> the following:
>
> --8<-------------------------- separator ------------------------>8--
> === sending via gmail ===
> Sending...
> Sending via mail...
> open-network-stream: Failed connect: Operation timed out
> --8<-------------------------- separator ------------------------>8--
>
> I feel like I’m close, but there’s something still not quite
> right. If you have any insights on what might be going wrong or any
> tweaks I should try, I’d really appreciate it.