koldfront

Gnus email tutorial

This tutorial will show you how to set up Gnus in Emacs to read your email. You are assumed to have basic knowledge of Emacs and to be motivated to use Gnus - oh, and you probably run a reasonably Unix-like operating system.

Table of contents

Installing

I will be putting Emacs-configuration in ~/.emacs.d/init.el and Gnus-specific configuration in ~/.gnus.

I will be presenting Gnus in the newest version included in the stable release of GNU Emacs, so you needs GNU Emacs 25 or newer.

The basics

The first thing to do is to configure how you want your email stored. In this tutorial, I assume that you want to have Gnus take your email and store it locally, and you don't care that other mail programs can not read the email. (When you have finished this page, you can go on to read about IMAP.)

Where to get email (or news) from is defined by so-called "select methods".

For historical reasons, Gnus has a single "primary" select method and multiple "secondary" select methods. The only difference is that the primary select method has a default (tries your local news server), and the groups (folders) in it are not prefixed with the server name.

Because I don't like to put anyone on a piedestal - except perhaps Bob Dylan, but anyway - I choose to make the primary select method one that does nothing - that way all the "real" servers are equal.

So I add this to ~/.gnus (to avoid Gnus trying to connect to a non-existing local news server):

; No primary server:
(setq gnus-select-method '(nnnil ""))

For now, we only want one server, the one that will store our email, so let's set that up in ~/.gnus:

; Get email, and store in nnml:
(setq gnus-secondary-select-methods '((nnml "")))

Gnus can handle, and store, email in many different ways. nnml is a good choice if Gnus is the only program modifying the emails. nnml defaults to store each group in a directory underneath ~/Mail/ - with each email in a file by itself.

(You can use nnmaildir if you want to share the email on the filesystem level with another email program that reads Maildir format, and you can use nnimap if you want to access email on an IMAP server - more on that later.)

You might be asking yourself: "Where is Gnus going to fetch email from?!" This is defined by the mail-sources variable, which defaults to getting it from ((file)), which usually means something like your local /var/mail/$USER.

That's pretty much it - you could start Emacs and go M-x gnus now and start reading your email. Simple, eh?

But this is Gnus/Emacs, so let's configure a few more nice things before going on.

Just a little customization

Name and rank, please

Emacs and Gnus try to pick up your name and email-address from the operating system, but what it picks up might not always be what you wanted. The easy fix is to configure your name and email address in ~/.emacs.d/init.el thus:

; Set name and email:
(setq user-full-name "Adam Sjøgren"
      user-mail-address "adsj@koldfront.dk")

Splitting

You probably want to split your email out into various groups. Gnus can be configured to do this according to a set of rules. I will start of with a very simple set, and gradually expand them as the need/the ideas come to me. So I will just start with emails from cron going to a special group, called nnml:system, and the rest into a group called nnml:normal:

; Use fancy splitting:
(setq nnmail-split-methods 'nnmail-split-fancy)

; Email splitting rules:
(setq nnmail-split-fancy
      '(|
          ("From" "\\(root\\|cron\\)@koldfront.dk" "system")
          "normal"))

You can check your splitting rules using B q on an email - it will tell you what group the email would be split in according to the current rules. If you want Gnus to do so, you can use the B r command.

Topics

Gnus allows you to manage your groups in topics, so you can have different, nested topics, instead of a flat list of groups. That is pretty nice, so I turn that on in ~/.gnus:

; Use topics per default:
(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)

Article display

I sometimes receive multipart MIME emails, so this can be nice to have in ~/.gnus:

; Show more MIME-stuff:
(setq gnus-mime-display-multipart-related-as-mixed t)

... and I like to have me some colourful smileys:

; Smileys:
(setq smiley-style 'medium)

One last, tiny thing: Gnus defaults to opening the first email when you enter a group, also it shows an arrow at the current email. I think that is highly annoying; fortunately it is easy to remedy by sticking this in your ~/.gnus:

; Don't get the first article automatically:
(setq gnus-auto-select-first nil)

; Don't show that annoying arrow:
(setq gnus-summary-display-arrow nil)

Let's go!

Ok, that's pretty much it, so let us fire up Emacs and press M-x gnus. Gnus will now start, display the logo and get any email you have waiting.

So, where is all the email I just said would be fetched? Well, you have subscribe to the mail groups. So go F to find new groups, and your new group nnml:normal will appear.

This is what it looks like, then:

Emacs with Gnus started

Arranging your groups into topics according to taste and hierarchical preferences is left as an exercise for the reader. Hint: Check out the "Topics" menu for ideas.

Further reading...

Topics to cover as time permits:

Contact

If you have any comments, ideas or corrections, don't hesitate to email me.

0.0025 s
webcustodian@koldfront.dk