e-mails on Emacs: #1 - #2 - #3 -#4

In the below I describe Gnus, which is the built-in news and mail reader for emacs.

Rant

Before we begin, a big disclaimer: I don’t recommend using Gnus for someone who didn’t emacs for at least 6 months (and ended up loving it). The reasons is the difficulty in the initial set up. I mean, it has an awful, awful, awful onboarding. The worst I have ever seen. However, once you’re over that, my experience is that it was worth it. It has a different approach to dealing with mail (basically it treats it as a newsgroup), an approach that I find useful. I will discuss another approach, the search approach with the emacs package mu4e later.

So let me give you an idea of what I mean when I said it has an awful onboarding. You start Gnus with the M x gnus command, and that results in an error when you first use it. You’re like ok, I’ll go read the documentation. And there you read and find out that you have to enter something you probably don’t know (have you heard of the NNTP protocol?) in a file that doesn’t yet exist yet (~/.gnus.el). And this is the only example it gives you. Later (assuming you continue reading the documentation and its weird humor) you find out that there are different ways to do tasks like adding a group that probably were added along the years. However, those too aren’t smooth and straightforward and the documentation wasn’t updated to put the easy way first.

Then I went on Youtube and saw Dick Mao, I was impressed by how he uses emacs. It was still hard to use Gnus after watching this short video, but I got inspired. Also, the idea that it’s the official emacs email/newsreader, and that it must make sense at the end, kept me going.

The Right Way

So here is how to learn gnus in 2022. To learn the very basics, start with this video by Stavrou1 Emacs: introduction to GNUS to get a feel of what Gnus is. Then read A Practical Guide to Gnus.

The best way to learn computer programs is by using them. To start using Gnus, you need to add a group (gnus lingo for “mailbox”, or “news source”). The easiest way to add a group is probably adding an RSS group. Simply type G R from the *Group*2 buffer, as described in the emacs wiki. If you would like to add your email accounts, you can find more guides and their short version below.

Adding Groups (Accounts): Examples

So you don’t get lost in the details, just know there are 2 protocols used for receiving email: POP3 and IMAP (which most people use), and one for outgoing mail called SMTP. You need to tell emacs the address and the address, the port, and whether the stream is encrypted or not.

Protonmail

Gnus + protonmail (requires Bridge)

The short version of the above link is just putting the following in ~/.gnus.el then starting gnus

(setq gnus-select-method '(nnimap "localhost"
				  (nnimap-stream plain)
				  (nnimap-address "127.0.0.1")
				  (nnimap-server-port "1143")
				      )
      )

This option requires a paid membership to get the Bridge feature of protonmail. When prompted for a password, you put the one supplied by the bridge application. Note: you might get a warning that the connection between emacs and localhost is unencrypted. You can safely ignore this warning according to the reason mentioned in this reddit post.

Gmail

Gnus + Gmail

This guide describes how to add a gmail account to Gnus. The short version: add the following to ~/.gnus.el then (re)start gnus

(setq gnus-select-method
      '(nnimap "gmail"
	       (nnimap-address "imap.gmail.com") 
	       (nnimap-server-port "imaps")
	       (nnimap-stream ssl)))

(setq smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 587
      gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")

Exchange Server

I have to research this more, but this command was enough to set up Gnus on my work laptop, where we use Microsoft Exchange. On the internal network, after adding the following to ~/.gnus.el it just asked for me for my credentials and then connected. However, it only works inside this network.

(setq gnus-select-method '(nnimap "imap.myserver.org"))

RSS

Here is how to subscribe to CNN on gnus. You can practice modifying the *Summary* buffer from there

(setq gnus-secondary-select-methods '((nnrss "http://rss.cnn.com/rss/edition.rss")))

  1. One of the nice features of Gnus is how it integrate with org-capture. You can capture tasks from your email to org mode and add a link to the email with one keybinding (see here min 09:00). 

  2. Gnus has 3 main buffers, the *Group* buffer (for “mailboxes” and newsgroups), the *Summary* buffer for the list of items (articles) inside groups, and the article buffer. Each of these buffers has a different set of commands.