There are many “set up Gnus to read email from Emacs on Windows” posts. This one is mine. Unlike the 10,000 others on the internet, this one actually worked for me.
A nice thing is that, with a few tweaks, this setup also works on UNIX-like machines.
PREREQUISITES
- Emacs: https://ftp.gnu.org/gnu/emacs/windows/
- stunnel for Windows: https://www.stunnel.org/downloads.html
-
Patience :-)
OVERVIEW
At a high level, the way this all works is that:
- A mail server is out there on the interwebs somewhere
-
stunnel runs locally, and creates an encrypted “tunnel” between a port on the mail server and a port on the local machine
-
Emacs (Gnus) connects to the local port and fetches mail from there (as far as it knows)
STEP 1. INSTALL AND CONFIGURE STUNNEL
Download and install stunnel for Windows:
https://www.stunnel.org/downloads.html
I use Fastmail, so the following configuration worked for me. I put it in the file ‘C:/Users/rml/_stunnel.conf’.
# Windows stunnel config # 1. GLOBAL OPTIONS debug = 7 output = C:/Users/rml/Desktop/stunnel.log # 2. SERVICE-LEVEL OPTIONS [IMAP (rmloveland@fastmail.fm) Incoming] client = yes accept = 127.0.0.1:143 connect = mail.messagingengine.com:993 [SMTP (rmloveland@fastmail.fm) Outgoing] client = yes accept = 127.0.0.1:465 connect = mail.messagingengine.com:465
If memory serves, you will need to do some messing around with stunnel to get it to read from a config file other than the default. Luckily it puts a little icon in the notification tray that you can right-click to get it to do things such as edit the config file or view the log file. From there, you should be able to get the config in shape as shown above.
In the particular case of Fastmail, you’ll need to set up an app password via its web UI. See your email provider’s documentation for more information.
STEP 2. CONFIGURE GNUS
On the Emacs side, we need Gnus to ask the right port on the local machine for mail. Here’s what I did:
(setq send-mail-function 'smtpmail-send-it message-send-mail-function 'smtpmail-send-it smtpmail-smtp-server "localhost" smtpmail-smtp-service 465 smtpmail-stream-type nil smtpmail-default-smtp-server "localhost")
This is the part of your Gnus config that tells it how to talk to stunnel; all of the other Gnus things are beyond the scope of this article. If you need more Gnus info, you should be able to get something going using the EmacsWiki:
https://www.emacswiki.org/emacs/CategoryGnus