Mail with Gnus on Windows

Update 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 [email protected] password mysecretapppassword
machine imap.gmail.com login [email protected] password mysecretapppassword port 993
machine smtp.gmail.com login [email protected] 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 "[email protected]" nil))
      smtpmail-auth-credentials '(("localhost" 25 "[email protected]" 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 "[email protected]")

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))))

One Pingback/Trackback

    21 November 2015 at 1:11pm
    […] So, of course, Sacha Chua decided to do both at the same time. ...
  • GNUS on Windows | Irreal
  • Will

    Sacha, 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.

  • Pingback: GNUS on Windows | Irreal()

  • Thomas Worthington

    Sacha, you’ve spelt your name wrong in that first link to your config :)

    • Hah! =) Fixed. Thanks!

  • Dhavan Vaidya

    Thanks 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!

  • Jörg Reuter

    That’s a nice tutorial. Even without GPG very good. Maybe you still do not know it:
    https://github.com/kensanata/ggg

  • narendraj9

    Hi, 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.

    • Mmm… 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.ru/doc/em24h/emacs183.htm 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!