On Thu, Sep 05 2024, Serghei Iakovlev via "Announcements and discussions for
GNUS, the GNU Emacs Usenet newsreader (in English)" <[email protected]>
wrote:
> Hello everyone,
>
> I'm currently working on setting up Gnus for sending emails over IMAP
> depending on which email account I'm using. I have two accounts:
> ProtonMail and Gmail. Receiving emails works fine for both, but I'm
> struggling with sending. Here's the error I encounter in the
> *Messages* buffer:
>
>
> Sending via mail... gnutls.el: (err=[-15] An unexpected TLS packet
> was received.) boot: (:priority NORMAL:%DUMBFW :hostname
> smtp.gmail.com :loglevel 0 :min-prime-bits nil :trustfiles
> (/etc/ssl/cert.pem) :crlfiles nil :keylist nil :verify-flags nil
> :verify-error nil :callbacks nil) gnutls-negotiate: GnuTLS error:
> #<process smtpmail>, -15
>
>
> What I'm aiming to achieve is the ability to send messages, including
> responding from Gmail to emails received on Gmail. Here's the
> relevant snippet of my configuration:
>
> (setq gnus-secondary-select-methods
> '((nnimap "main"
> (nnimap-address "127.0.0.1")
> (nnimap-server-port 1143)
> (nnimap-stream starttls)
> (nnimap-inbox "INBOX")
> (nnimap-expunge never)
> (nnmail-expiry-wait immediate)
> (nnmail-expiry-target "nnimap+main:Trash"))
> (nnimap "gmail"
> (nnimap-address "imap.gmail.com")
> (nnimap-server-port "imaps")
> (nnimap-stream ssl)
> (nnimap-inbox "INBOX")
> (nnimap-expunge never)
> (nnmail-expiry-wait immediate)
> (nnmail-expiry-target
> "nnimap+gmail:[Gmail]/Trash"))))
>
>
> (setq gnus-posting-styles
> `((".*"
> (signature ,user-full-name)
> ("GCC" "nnimap+main:Sent"))
> ("nnimap\\+gmail:.*"
> ("GCC" "nnimap+gmail:[Gmail]/Sent Mail")
> ("X-SMTP-Server" "smtp.gmail.com")
> ("X-Message-SMTP-Method"
> "smtp smtp.gmail.com 587 [email protected]")
> (address "[email protected]"))))
>
> (setq message-send-mail-function 'message-smtpmail-send-it)
> (setq send-mail-function #'smtpmail-send-it)
>
> (setq smtpmail-default-smtp-server "127.0.0.1")
> (setq smtpmail-smtp-service 1025)
> (setq smtpmail-stream-type 'ssl)
>
>
> From what I can tell, this setup isn't working because Gmail uses
> port 587, but I've explicitly set it to port 1025 since that's the
> port I use for communication with Proton Bridge.
>
> I have a few questions:
>
> 1. How would you idiomatically resolve this issue?
> 2. What’s the correct approach when dealing with multiple accounts
> like this?
> 3. Is it appropriate to use gnus-posting-styles to override things
> like the SMTP server?
> 4. Should I use X-SMTP-Server as well as X-Message-SMTP-Method?
>
> I would appreciate any advice or insights you might have on how to
> handle this properly.
>
> Thanks in advance for your help!
I use gnus-posting-styles and X-Message-SMTP-Method to setup the reply
for each of my accounts (I use Gnus to manage 3 or 4 email accounts,
including a gmail one). For example, in the current buffer, Gnus has
inserted
I do not have `smtpmail-default-smtp-server' set.
This is the only way that I have found to reliably get Gnus to work with
multiple smtp servers.
Best regards,
Leo