Chapter 12. Reading and writing e-mail with mutt

Table of Contents
12.1. Introduction
12.2. Usage
12.3. Basic setup
12.4. Signing/encrypting e-mails

12.1. Introduction

Mutt is a mail user agent (MUA) that can be used for reading and writing e-mail. Mutt is a text-mode installation, meaning that it can be used on the console, over SSH and in an X terminal. Due to its menu interface, it is very easy to read large amounts of e-mail in a short time, and mutt can be configured to use your favorite text editor.

This chapter will discuss how you can customize mutt for your needs, how to use it, and how PGP/GnuPG support is used.

12.2. Usage

Mutt is pretty simple to use, though it may take some time to get used to the keys that are used to navigate, read and write e-mails. The next few sections describe some of the more important keys. Mutt provides a more thorough overview of available keys after pressing the <h> key.

12.2.1. Browsing the list of e-mails

After invoking the mutt command, an overview of all e-mails will show up. You can browse through the list of e-mails with the up and down arrow keys, or the <k> and >j> keys.

12.2.2. Reading e-mails

To read an e-mail, use the <Enter> key, after selecting an e-mail in the overview of e-mails. When reading an e-mail you can use the <Page Up> and <Page Down> to browse through an e-mail. You can still use the navigational keys used to browse the list of e-mail to browse to other e-mails.

If an e-mail has any attachments, you can see them by pressing the <v> key. You can view individual attachments by selecting them and pressing the <Enter> key. To save an attachment to a file, press the <s> key.

12.2.3. Sending e-mails

You can compose a new e-mail with the <c> key, or reply to a selected e-mail with the <r> key. Mutt will ask you to specify the recipient (To:), and a subject (Subject:). After entering this information an editor is launched (vi is used by default), which you can use to compose the e-mail. After saving the e-mail, and quitting the editor, mutt will give you the opportunity to make any changes to the e-mail. If you decide that you want to alter the e-mail, you can restart the editor with the <e> key. You can change the recipient or the subject with respectively <t> or <s>. Finally, you can send the e-mail by pressing <y>. If you would like to cancel the e-mail, press <q>. Mutt will ask you whether you want to postpone the e-mail. If you do so, you will be given the opportunity to re-do the e-mail the next time you compose a message.

12.3. Basic setup

There are a few mutt settings you often want to configure. This section describes these settings. User-specific mutt customizations can be made in the .muttrc in the user's home directory. You can change global mutt settings in /etc/mutt/Muttrc.

12.3.1. Customized headers

Each e-mail has headers with various information. For example, the header contains information about the path an e-mail has traversed after it has been sent. The sender (From:) and recipient (To:) e-mail addresses are also stored in the headers, as well as the subject (Subject:) of an e-mail.

Note

In reality the To: header is not used to determine the destination of an e-mail during the deliverance process of the e-mail. MTAs use the envelope address to determine the destination of the e-mail. Though, most MUAs use the To: address that the user fills in as the envelope address.

You can add your own headers to an e-mail with the my_hdr configuration option. This option has the following syntax: my_hdr <header name>: <header contents>. For example, you can add information about what OS you are running by adding the following line to your mutt configuration:


my_hdr X-Operating-System: Slackware Linux 10.2
      

You can also override some of the headers that are normally used, such as the sender address that is specified in the From: header:


my_hdr From: John Doe <[email protected]>
      

12.3.2. The sendmail binary

By default mutt uses the sendmail MTA to deliver e-mails that were sent. You can use another command to send e-mail by altering the sendmail configuration variable. The sendmail replacement must handle the same parameter syntax as sendmail. For example, if you have installed MSMTP to deliver e-mails, you can configure mutt to use it by adding the following line to your mutt configuration:


set sendmail="/usr/bin/msmtp"
      

When you have completely replaced sendmail with another MTA, for instance Postfix, it is usually not needed to set this parameter, because most MTAs provide an alternative sendmail binary file.

12.4. Signing/encrypting e-mails

12.4.1. Introduction

Mutt provides excellent support for signing or encrypting e-mails with GnuPG. One might wonder why he or she should use one of these techniques. While most people do not feel the need to encrypt most of their e-mails, it generally is a good idea to sign your e-mails. There are, for example, a lot of viruses these days that use other people's e-mail addresses in the From: field of viruses. If the people who you are communicating with know that you sign your e-mails, they will not open fake e-mail from viruses. Besides that it looks much more professional if people can check your identity, especially in business transactions. For example, who would you rather trust, [email protected], or someone using a professional e-mail address with digitally signed e-mails?

This section describes how you can use GnuPG with mutt, for more information about GnuPG read Section 8.7.

12.4.2. Configuration

An example configuration for using GnuPG in mutt can be found in /usr/share/doc/mutt/samples/gpg.rc. In general the contents of this file to your mutt configuration will suffice. From the shell you can add the contents of this file to you .muttrc with the following command:


$ cat /usr/share/doc/mutt/samples/gpg.rc >> ~/.muttrc
      

There are some handy parameters that you can additionally set. For example, if you always want to sign e-mails, add the following line to your mutt configuration:


set crypt_autosign = yes
      

Another handy option is crypt_replyencrypt, which will automatically encrypt replies to messages that were encrypted. To enable this, add the following line to your mutt configuration:


set crypt_replyencrypt = yes
      

12.4.3. Usage

If you have set some of the automatical options, like crypt_autosign GnuPG usage of mutt is mostly automatic. If not, you can press the <p> key during the final step of sending an e-mail. In the bottom of the screen various GnuPG/PGP options will appear, which you can access via the letters that are enclosed in parentheses. For example, <s> signs e-mails, and <e> encrypts an e-mail. You can always clear any GnuPG option you set by pressing <p> and then <c>.