Use Mutt in ArchLinux
Contents
I successfully configured the Mutt email client a long time ago. Many open-source communities continue to use mailing lists as their primary communication tool, making a plain text email client essential. Mutt is an excellent choice for this purpose. I wrote this blog post to deepen my understanding of Mutt’s processes and to share why it remains relevant and useful in today’s digital communication landscape.
The following contents are cited from Mutt ArchWiki:
Mutt focuses primarily on being a Mail User Agent (MUA), and was originally written to view mail. Later implementations (added for retrieval, sending, and filtering mail) are simplistic compared to other mail applications and, as such, users may wish to use external applications to extend Mutt’s capabilities.
Nevertheless, the Arch Linux mutt package is compiled with IMAP, POP3 and SMTP support, removing the necessity for external applications.
Although the ArchLinux mutt package includes SMTP protocol functionality, which could simplify email management, I have decided to stick with the traditional way of using Mutt. This approach allows me to fully understand and control the email handling process, ensuring that I can customize and optimize it according to my specific needs.
I decide to use the following softwares in Arch Linux (It should work in any UNIX-like environment).
- fetchmail. It is a mail-retrieval and forwarding utility; it fetches mail from remote mail servers and forwards it to your local machine’s delivery system.
- procmail. A program for filtering, sorting and storing email.
- Mutt. The MUA.
- msmtp. A simple SMTP client.
The Usage of fetchmail
It’s not hard to use fetchmail
. You should carefully read its manual. It will explain everything you need.
1 | # QQMail (FoxMail) |
The fetchmail
will eventually call procmail
for directing the emails.
The Usage of procmail
The functionality of procmail
is very powerful. However, power sometimes can cause a lot of trouble. So, I only use procmail
to put the received email into the corresponding inbox.
1 | MAILDIR=$HOME |
The configuration described above is straightforward. It efficiently examines both the To and Cc fields of an email and directs the message to the appropriate folder accordingly.
The Usage of mstmp
It’s still not so hard to configure the mstmp
.
1 | # QQMail (FoxMail) |
The Usage of Mutt
Theme
I use the dracula theme.
1 | # Dracular color theme |
Basic Configuration
The configuration could be very different for different people. I simply put my configuration below. You’d better use the man muttrc
to change the configuration for whatever you like.
1 | # The default directory to save attach_save_dirachments from the "attachment" menu. |
Use w3m To View HTML Content
I don’t want to use external browser to view HTML content. I use Reading html email with mutt as the reference to setup. It’s not hard.
We need to first change the mutt
configuration like the following:
1 | # Set w3m to view html content |
And the add the following content to the ~/.mailcap
:
1 | text/html; w3m -I %{charset} -T text/html; copiousoutput; |
Use Zathura to View PDF File
Append the following content to the ~/.mailcap
:
1 | application/pdf; zathura %s; |
Vim Bindings
Please refer to this wonderful blog Mutt, the Vim Way.
Multiple Accounts Support
We could use Mutt hook functionality to support multiple accounts. For multiple accounts, you must use account-hooks and folder-hooks.
- Folder-hooks will run a command before switching folders. This is mostly useful to set the appropriate SMTP parameters when you are in a specific folder. For instance when you are in your work mailbox and you send an e-mail, it will automatically use your work account as sender.
- Account-hooks will run a command every time Mutt calls a function related to an account, like IMAP syncing. It does not require you to switch to any folder.
I use folder-hooks because there is no account configuration for mutt. I use Gmail as the master configuration in muttrc
like the following:
1 | # GMail as the master |
Below is a full example for GMail and QQMail.
1 | # ~/.config/mutt/accounts/GMail |
Reference
Author: shejialuo
Link: https://luolibrary.com/2024/05/12/Use-Mutt-in-ArchLinux/
License: CC BY-NC 4.0