Mail with Gnus on Windows
Posted: - Modified: | emacsUpdate 2015-11-26: fixed link to my config. Thanks, Thomas!
I use Gmail for my mail because it:
- synchronizes with my phone, which is handy for notifications and quick replies
- filters most of the spam for me
- works with a few interesting extensions such as Boomerang for Gmail
However, I like the way the Gnus mail/news client in Emacs gives me a much more keyboard-friendly way to manage lots of mail, and I can even write code to partially automate some of my common operations.
I used to have my config in in ~/.gnus
, but people might find it handy, so I’ve added it to my public Emacs configuration.
I like using Gmane to read mailing lists, and I use IMAP to read my Gmail.
(setq gnus-select-method '(nnnil "")) (setq gnus-secondary-select-methods '((nntp "news.gmane.org") (nnimap "imap.gmail.com" (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnimap-stream ssl) (nnimap-authenticator login))))
I have two-factor authentication enabled for Gmail, so I set up an app-specific password for Gnus. I have an ~/.authinfo
file set up with something like:
machine imap.gmail.com login sacha@sachachua.com password mysecretapppassword machine imap.gmail.com login sacha@sachachua.com password mysecretapppassword port 993 machine smtp.gmail.com login sacha@sachachua.com password mysecretapppassword port 587
(I should probably get around to using GPG to automatically encrypt and decrypt this file.)
Sending e-mail on Windows was a bit of a pain. Fortunately, I eventually found something that works. I’ve configured emailrelay to accept the mail and forward it to Gmail. The server starts with this batch file:
start "emailrelay" "C:\Program Files (x86)\emailrelay\emailrelay.exe" --as-proxy smtp.gmail.com:25 --client-auth "C:/sacha/.emailrelay" --client-tls --log --pid-file "C:\Program Files (x86)\emailrelay\emailrelay.pid" --spool-dir C:\sacha\tmp\emailrelay
Sending queued mail works with this batch file:
"c:\Program Files (x86)\emailrelay\emailrelay.exe" --as-client smtp.gmail.com:587 --client-auth c:\sacha\.emailrelay --client-tls --spool-dir c:\sacha\tmp\emailrelay
I should probably get around to using --as-proxy
properly, since it still seems to hold mail until I explicitly send it.
Some more config. Not sure how much of this is needed.
(setq message-send-mail-function 'smtpmail-send-it smtpmail-starttls-credentials '(("localhost" 25 "sacha@local.sachachua.com" nil)) smtpmail-auth-credentials '(("localhost" 25 "sacha@local.sachachua.com" nil)) smtpmail-default-smtp-server "localhost" smtpmail-smtp-server "localhost" smtpmail-smtp-service 25 smtpmail-local-domain "local.sachachua.com") (setq send-mail-function 'smtpmail-send-it) (setq smtpmail-smtp-server "127.0.0.1") (setq smtpmail-smtp-service 25) (setq user-mail-address "sacha@sachachua.com")
Hide HTML mail. I need to fiddle with this some more, since Gnus still tries to display them. Sometimes my Gnus crashes when it tries to display HTML mail.
(setq mm-discouraged-alternatives '("text/html" "text/richtext") mm-automatic-display (-difference mm-automatic-display '("text/html" "text/enriched" "text/richtext")))
Hide quoted text.
(setq gnus-treat-hide-citation t)
Get smarter about filtering depending on what I reed or mark. I use !
(tick) for marking threads as something that interests me.
(setq gnus-use-adaptive-scoring t) (setq gnus-default-adaptive-score-alist '((gnus-unread-mark) (gnus-ticked-mark (subject 10)) (gnus-killed-mark (subject -5)) (gnus-catchup-mark (subject -1))))
10 comments
Will
2015-11-20T22:39:42ZSacha, thank you for posting this! I'm just getting up and running with Gnus (not hard to get it up and running but the Gnus way of doing things is very different) and with Emacs on Windows so this is very handy.
Thomas Worthington
2015-11-24T16:51:16ZSacha, you've spelt your name wrong in that first link to your config :)
sachac
2015-11-27T02:43:55ZHah! =) Fixed. Thanks!
Dhavan Vaidya
2015-12-02T08:59:54ZThanks for posting this. I have been trying to set up gnus for my mail server and this is the best and easiest way I found. Also, got a nice suggestion for news server!
sachac
2015-12-07T15:36:03ZGlad it was helpful!
Jörg Reuter
2016-03-28T21:59:04ZThat's a nice tutorial. Even without GPG very good. Maybe you still do not know it:
https://github.com/kensanat...
narendraj9
2017-12-10T06:29:57ZHi, thanks for the great article. I have question:
Is it possible to use `gnus` filtering capabilities to have replies to a question that I posted in a mailing list be filtered into my Primary group while keeping other messages from the mailing list there? This would help me get to my emails quickly if the mailing list has high traffic.
sachac
2017-12-11T09:57:51ZMmm... I used Gnus scoring to do something like that, since you can use adaptive scoring to automatically score up responses to you. http://www.emacs.uniyar.ac.... might have more information. I mostly use keywords (and generally ignoring mail) now, though, since I have much less computer time than I used to!
Christian Arthaber
2018-04-08T18:48:03ZHi, thanks for the interesting article. For what it's worth: Using the latest native emacs on Windows (including the deps.zip) Gnus works out of the box with gmail.
Hugo Chang
2024-12-20T00:39:45ZSacha, thank you for sharing this! I’m just getting started with Gnus (it’s not difficult to set up, but the Gnus way of doing things is quite unique) and using Emacs on Windows, so this is incredibly helpful. I was also wondering if you’ve had any experience creating org links with [[gnus:]]. I’ve tried multiple times but haven’t been successful. Do you have any advice for me? Thank you!