Thinking Outside the Mailbox
Using mutt to refer to mail messages from outside the mailer, saving them to files and working with them with other programs, following the UNIX spirit.
1 Message IDs
There's a wealth of metadata that comes with a mail, beyond what you'll see at first sight which is the sender, recipient, date and subject. At a single keystroke, mutt can show you much more still. Hitting H will display all the headers and there is one in particular that drew my attention early on when I started using mutt all these years ago: the Message-ID
, a string looking like 123456789abc@example.com
.
Unless you start duplicating messages in your mailbox, this ID is crafted to be unique, which makes it useful to refer to a specific message. Mailers like mutt can use it for searching and filtering. Hitting L and using the ~i
pattern modifier (e.g. ~i 123456789abc@example.com
) will list that one message holding the ID.
What's interesting, is that the copy of a message you send and which will be recorded e.g. into your sent mail box will share the same ID as the copy in your recipient's inbox. So if your recipient knows how to work with message IDs you can refer to them so they uniquely know which message you're referring to.
I also use IDs all the time to refer to messages from my calendar program, task manager or notebook if I want to refer to details in a specific message from which I created an event, task or snippet of information. This has become so useful in fact that I've set up mutt to display the message ID in colour to make it stand out from the rest of the header:
color header yellow default "^message-id:"
2 Saving Messages
I can imagine a few circumstances in which only referring to messages with their ID isn't practical. It can be useful to write the message to file instead. Mutt distinguishes between saving and copying. Where saving assumes removing the original message (i.e. moving), copying means literally copying it. Copying is probably what you want in practice. Whether you choose to save or copy, mutt gives you the ability to decode beforehand, which means that funny characters such as accents will be more human-readable and some information will be dropped from the header (the message ID will be kept, however).
In essence:
S | Save (i.e. move) |
ShiftC | Copy |
Esc then S | Save (i.e. move) after decoding |
Esc then ShiftC | Copy after decoding |
3 Working with Messages
With a message you've saved to file, what you can do knows no limit. You can edit them with your favourite editor, send them on by mail, index them to search them swiftly or displaying them nicely in other documents. That's in fact something I quite like doing with Pandoc which supports the email
syntax highlighting language such that if you wrap up your decoded message in:
```email
Date: ...
From: ...
To: ...
Subject: ...
...
```
... and run:
pandoc -f markdown decoded -o decoded.pdf
... you will get a nice rendering of your mail with colours.