— 04 November, 2013

On my way to meet the default UNIX tools, I ran into a simple one: mail, that
was sitting in the corner of my system playing with.. Nothing in fact.mail is one of that small utilities that have been forgotten and replaced by
more "moderns" tools like mutt, alpine or even thunderbird. But it is worth
knowing about !

mail can manipulate a mail box in either mbox or Maildir format, and is
intelligent enough to know the difference between the two of them.
It can also handle IMAP mail boxes, but for this post, I'll assume you use a
local mail directory under $HOME/var/mail/INBOX/

Because we all need that bearded touch, we will use mail as our main mail
user agent.

The environment

As any of the standard UNIX tool, mail integrates well in a UNIX environment,
and is able to interact with external tools to perform specific action (assume
it, you love that huh?).

Here is the set of variable mail is going to use:

MAIL: The default mail box

EDITOR: The default editor to use

VISUAL: The default visual editor to use

And that all ! We will not need more to get a running set up (For
more infos, you can check the mail(1) manpage).

Ok, now the mail environment is set up. You can try the mail command at this
point, but an empty mail tree will only result in the following message:

No mail for z3bra

For future convenience, copy your /etc/mail.rc to
~/.mailrc, so we will be able to edit it later.

Before continuing with mail, we will take a look at two mail related programs,
fdm and msmtp,
that we will use to fetch and deliver emails.

Fetching mails

FDM stands for Fetch and Deliver Mails, so it basically get mails from a
server, and place them in your local filesystem based on regex rules.
If you want a great tutorial for fdm, check out the
FDM Quick start guide. I'll just give you my
own (simplified) config file:

The ? at the end is a prompt. You can input commands like print <num> to
display the content of the mail number "num".
You can use abbreviations for commands: "p" is the same as "print". "e" means
"edit", "v" means "visual".

There are A LOT of commands (to delete mails, encrypt/decrypt, copy to folders,
manage aliases, ...)

You can even define macros, to make action like, add sender to aliases, mark as
read, copy to another folder and delete the current mail.

Today, I discovered mail which does anything I need to manage my e-mails. I'll
probably make the switch from mutt on all my machines once I'll be used to it.

This little discovery reminded me that UNIX was and still is a great operating
system, regardless of all the tools that have been developped since its birth.

I hope you (re)learnt something with this article. I don't hear about mail
that much nowadays, although it's really usable and functionnal. I feel like a
pokemon hunter. Aware that there are many, many tools out there, of different
forms, with different purpose... I'll probably never use them all. But I'll try!