May 13th, 2019

Abstract
"Electronic mail (email or e-mail) is a method of exchanging messages ("mail") between people using electronic devices. Invented by Ray Tomlinson, email first entered limited use in the 1960s and by the mid-1970s had taken the form now recognized as email." [1]^ Email has been around for more than 50 years now. As we go further on our timeline, folks from new generations are starting to forget the beauty of email. This article will discuss the problems with the current state of emails and the ways to bring back joy into it.

Problems with modern email

When you ask someone to check their email, I am sure they would rather use their phone if they do not have one open already on their computer. The reason for this is the discomfort people have opening their email services in their browsers. The key for this discomfort is time. When I open my email on my laptop, it takes about 5-6 seconds to just open my browser, 2-3 more seconds to enter the email address, and God knows how much longer until my inbox actually opens. Looking at you, Gmail.

People want their services to work fast and without any delays. Phones have apps that open and become operational with just a tap of a finger. However, phone apps are not very extensive in their functionality (attaching files, sorting mail, flagging email, bulk delete) and they do not offer a full range of formatting tools. By all means, they never had to, they are just expected to perform the most basic options.

Due to all the convenience that mobile apps offer, people choose to use it all the time instead of full clients, therefore limiting the number of actions they can make. They just reserve themselves to most basic functionality. Which is very and very unfortunate. Instead of progressing and learning new tools and better ways to perform tasks, users prefer to stick to what they know. This is not only an email problem, it is a general issue with most if not all technologies.

In reality, email is a fantastic way of communication. Indeed, it was the only way to communicate over the Internet back in 1970s and 1980s. As the time progresses and we create our future, developers around the world tried to work on email clients and unfortunately made them more unintuitive and less user-friendly. This beautiful way of communication became this big hassle of navigating to intermediate apps and typing a message.

Is there a solution for this unfortunate turn of events and overcomplication of email technology? I wish to introduce you to Mutt email client that brings back joy and happiness into emailing each other.

What is Mutt?

Mutt is a text-based email client developed by Michael Elkins in 1995 for UNIX-like systems. I want to say that this is truly the way emails were meant to be used. Before I start getting angry emails, I am aware of other fantastic TUI and ncurses email clients, such as: Gnus, Elm, and Alpine (Used by Brian Kernighan!). However, it is safe to say that Mutt is the most extensive, feature-rich, actively developed, and well-supported by its community. Just to list some of its features, please take a look at the excerpt from Mutt’s website below:

  • color support

  • active development community

  • full control of message headers when composing

  • highly customizable, including keybindings and macros

  • postpone message composition indefinetly for later recall

  • easily include attachments when composing, even from the command line

  • easy to install (uses GNU autoconf)

  • translation into at least 20 languages

  • small and efficient

  • It’s free! (no cost and GPL’ed)

  • and so much more!

Mutt accompanied with offlineimap will allow you to have all your emails saved on your machine so you will have a 24/7 access to them even if you do not have internet connection. You can write an email and postpone it indefinitely until your internet connection comes back. It also takes 0.1 seconds to boot it up and start composing a message. Do not forget about the aesthetics and romance with the terminal. Let us talk about the actual setup and what you have to do to be happy with your email experience.

IMAP and SMTP protocols

As you might know, email service in itself is relaying on several layers of protocols to retrieve and send mail. There is also POP3 protocol similar to IMAP. I will not discuss the differences between them, but I can assure you that IMAP is always a better choice as it is more organized in its nature. Internet Message Access Protocol or IMAP is used to retrieve all email messages from a mail server over a TCP/IP connection. This is the protocol we will use to download all our messages and store them locally. Simple Mail Transfer Protocol or SMTP is used for sending messages and handling remote mail server message transferring.

You can imagine that Mutt email client will rely on both of the protocols to operate normally. And you will be right. offlineimap is a program that allows us to use IMAP protocol and store all messages directly on our machine. There is also an option where you could use Mutt without offlineimap, it would mean that everytime you want to open your mailbox, Mutt will contact your mail server to download list of your messages. This is a very time expensive operation as it greatly depends on your bandwidth, internet location, and physical location from the mail server. Also, it would not allow you to access your messages without a constant internet connection. For this article, I will include full offlineimap configuration before we start using Mutt.

offlineimap

Installation

If you are using one of the bigger Linux distributions (Ubuntu, Fedora, Debian, and etc), it should already be installed. Try runnig % offlineimap to see if you have an active executable.

Note
% indicates that we are in the terminal. Everything after % should be executed.

If you do not have it installed, you can run % sudo pacman -S offlineimap on Arch Linux to install it or use python package manager pip to install it.

% pip install --user offlineimap

That should get you a fresh copy of offlineimap.

Configuration

offlineimap as a UNIX application, uses a configuration file, conveniently called .offlineimaprc. To make things easier, touch the file in your home directory or open your favorite tex editor, emacs, and write down the following:

~/.offlineimaprc
----------------
[general]
metadata = ~/.offlineimap
# You can change mymail to something else
accounts = mymail
socktimeout = 60

[Account mymail]
localrepository = local-mymail
remoterepository = remote-mymail

[Repository local-mymail]
type = Maildir
localfolders = ~/.mail/mymail

[Repository remote-mymail]
type = IMAP
remotehost = imap.site.com # edit this
remoteuser = myusername # edit this
remotepass = mypassword # edit this
ssl = yes
realdelete = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

This config file just gives us some details about how to contact the IMAP server and how to save it. mymail is any name of your choice. For my university mail, I have it named kumail, feel free to name it whatever name is convenient for you.

Local Repository gives info where it store all our email data, that would be .mail/mymail directory in your home directory. Remote repository is a bit more trickier but not difficult. It just specifies what you mail server is. Find your IMAP server, ports are not really important because they are usually the default ones (993). For example, my university has its IMAP server on imap.ku.edu. Username and password should be pretty obvious.

Syncing your mailbox

Just run the command below to synchronize your email server and your local mailbox.

% offlineimap

It will take a while to run this command for the first time because it has to download everything. Depending on your mailbox size, it may take a non-trivial time. Just be patient and let it do the magic for you. It is also a good advice for life. Just live the best you can, it will play itself out in the best way possible. Also, a little bit of faith always helps.

With this, we should be ready to comfortably start configuring our new email client.

Mutt and NeoMutt

So far, we talked about Mutt, but there is also a fork of it (same software with more features), called NeoMutt. We will be using it instead of Mutt as it is more extensible, faster, and backward-compatible with Mutt. You have same configuration files for both of them.

Installation

Installation of NeoMutt is super straight forward. Just pick your favorite flavor of Linux and install a package called neomutt. For Arch Linux, it just would be

% sudo pacman -S neomutt

Consult with the official downloads page for a list of the biggest distributions and how to install package on them.

Configuration

For the sake of brevity, I will brake down the configuration into multiple chunks. Firstly, I will talk about basic installation just to get a barebone version working, securing your password, and best of them all, making it super colorful, with signatures, ANSI escape sequences, and other cool stuff.

  1. Basic config

    Just to get you started, the drill is the same as the last time, but now it would be called ~/.muttrc The config file has a lot of different entries, so to keep it short, I will include the config file and it will be an exercise for the reader to get the meaning of the entries (this will be simple, I promise).

    # This should go to ~/.muttrc
    # Set up all the folders
    set folder="~/.mail/mymail"
    mailboxes = +INBOX
    mailboxes = +'Sent Items'
    mailboxes = +'Deleted Items'
    set spoolfile = +INBOX
    set trash = +'Deleted Items'
    set postponed = +'Drafts'
    set record = +'Sent Items'
    
    # Sort by reverse date
    set sleep_time = 0
    set sort = 'reverse-date'
    
    # Default sending charset
    set send_charset="utf-8"
    
    # SMTP FOR SENDING EMAIL
    set realname="Big Lebowski" # edit this
    set my_user=myusername # edit this
    set my_pass=mypassword # edit this
    set from = myaddress@example.com # edit this
    set smtp_url=smtp://\(my_user:\)my_pass@authsmtp.site.com:587 # edit this
    
    # Sending mail options
    set edit_headers=yes
    set use_from = yes
    set fast_reply=yes
    set include=no
    
    # SSL options
    set ssl_force_tls = yes
    set ssl_starttls = yes
    
    # Default text editor
    set editor = $EDITOR
    
    # Ways to open the mail messages
    auto_view text/html
    alternative_order text/plain text/html
    
    # Headers
    my_hdr X-Info: Keep It Simple, Stupid.
    my_hdr X-Operating-System: `uname -s`, kernel `uname -r`
    my_hdr User-Agent: Every email client sucks, this one just sucks less.
    
    set markers = no
    set mark_old = no
    
    set forward_format = "Fwd: %s"       # format of subject when forwarding
    set forward_decode                   # decode when forwarding
    set forward_quote                    # include message in forwards
    set reverse_name                     # reply as whomever it was to
    #set include                          # include message in replies
    
    auto_view text/html
    auto_view application/pgp-encrypted
    alternative_order text/plain text/enriched text/html
    set rfc2047_parameters = yes
    
    # Date and index formatting styles
    set date_format="%m-%d-%y %T"
    set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"# -*-muttrc-*-

    You can easily leave everything as it is, just edit all the lines with # edit this. Please pay a close attention to the line set smtp_url…​. You have to find your SMTP server address and port number (usually 587). After that, your email should be operational!

Make it cool

  1. Secure password

    You might not like that we store your password in plain text in your ~/.muttrc. I do not like it either. In this section, we will encrypt your email password and only you should be able te unlock it. We will encrypt your password with GPG. To do so, you have to have a pair of keys: public and private. To read more about public and private key encryption, visit its Wikipedia page.

    We will make you a pair of your own encryption keys to store your password in a very very secure way. .. Generating pair of keys

    + The following command will get you through everything

    +

    % gpg --gen-key

    + Make a new directory in your home directory with % mkdir ~/.mutt

    1. Creating password file

      You have to create your password with % echo set my_pass = 'mypassword' > ~/.mutt/mypass

      Important
      Put a space before the command so your system will not save your plain text password in its shell history.

      Encrypt the file with % gpg -r my_email -e ~/.mutt/mypass, where my_email is the email address you used when you created your key. You will have a new file called mypass.gpg that is your actual encrypted password.

      You can decrypt it and get the contents with % gpg -d ~/.mutt/mypass.gpg

      Remove the old file with % rm mypass

    2. Add key to Mutt

      Add the following line to the top of your ~/.muttrc: source "gpg -dq $HOME/.mutt/mypass.gpg |"

      Now, you can get rid of the plain text password from your ~/.muttrc and you are done! Try opening NeoMutt, it should ask you for your gpg password if you set up one.

  2. Add your signature

    Make your signature in the ~/.mutt/mysig.sig, for example

    ~/.mutt/mysig.sig
    -----------------
    Jack Bauer
    
    Director of C.T.U.
    Don't call me

    Add the line below to include your signature in every new email message. set signature = "$HOME/.mutt/mysig.sig"

  3. Encrypting your emails

    If you are feeling dangerous, you can start signing your emails, encrypting them, armored signatures, and other cool stuff. To do that, download this file, add that to your ~/.mutt/ directory, create one if you don’t have it, and add the following line to your _/.muttrc: source /.mutt/gpg.rc

    Press p when composing email to see the available options.

  4. Read web pages in your email

    Download this file, move the file to the ~/.mutt/ directory, add this line to your configuration file set mailcap_path = ~/.mutt/mailcap

  5. Make it corolful

    Make your NeoMutt look really good. Same drill.

    Download this file, move the file to the ~/.mutt/ directory, add this line to your configuration file source $HOME/.mutt/color.mutt

Conclusion

MAKE EMAIL GREAT AGAIN


1. Taken directly from Wikipedia