Mutt Mail Client In Linux

May 31, 2005
Mutt is a very powerful and flexible console based mail client available in Unix and Linux distributions. All aspects of the Mutt mail client can be configured to suite the mood of the user, and you have the power of command line to send and receive emails.

Mutt configuration file

Before you start using Mutt to send and receive emails, you need to configure it. This you do by creating a Mutt configuration file named .muttrc in your home folder.

Each user's .muttrc file is different. It can contain as little as your email id and POP/IMAP configuration or as much details as even setting the color of your Mutt interface.

As an example, When you read email using Mutt, by default you see the header of the email along with the message. You can hide all the email headers except the Subject:, To: and From: fields along with the actual message by inserting the following lines in your .muttrc file -

# File .muttrc
# ...
ignore *
unignore From: To: Cc: Subject: Date:
# ... 

Any line starting with a # is a comment in .muttrc.


A few examples of using Mutt

If your email account has POP3 access and you want to read the mail in Mutt, you can try the following command -

$ mutt -f pop://pop.myserver.com

Replace pop.myserver.com above with the POP3 server address of your email provider.

If you want to send and receive email securely, then use the command -

$ mutt -f pops://pop.myserver.com

To send email from the command line with a subject, use the following command -

$ mutt -s "subject line" name@email.com

To send an attachment with your message from command line -

$ mutt -s "attachment" -a data.doc name@email.com

How to access Gmail from Mutt


Finally, let me share with you my .muttrc file which I use to read mail from my Gmail account. It is a simple setup that uses IMAP in Gmail to access my mail.

You can reuse it for reading mails in your Gmail account too. Just change the strings highlighted in red to your own settings.

# Header stuff
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

ignore *
unignore from: date subject to cc
unignore x-mailing-list: posted-to:
unignore x-mailer:

# For better looks
set markers=no # don't put '+' at the beginning of wrapped lines
set pager_index_lines= 5 # how large is the index window?
set sort = 'threads'
set sort_aux = 'last-date-received'

# Gmail SETUP

set from = "myemail@gmail.com"
set realname = "Ravi"

set imap_user = "myemail@gmail.com"
set imap_pass = "my-gmail-password"

set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set trash = "imaps://imap.gmail.com/[Gmail]/Trash"


set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates

# SMTP settings for sending mail via Gmail

set smtp_url = "smtp://myemail@smtp.gmail.com:587/"
set smtp_pass = "my-gmail-password"

bind editor  noop
macro index gi "=INBOX" "Go to inbox"
macro index ga "=[Gmail]/All Mail" "Go to all mail"
macro index gs "=[Gmail]/Sent Mail" "Go to Sent Mail"
macro index gd "=[Gmail]/Drafts" "Go to drafts"

set move = no  #Stop asking to "move read messages to mbox"!
set imap_keepalive = 900

For a detailed explanation of the configuration listed above, visit this page.

There is a site called muttrcbuilder.org that will automatically create a .muttrc file for you.


How to install Mutt in Linux

Mutt mail client is available in most Linux distributions. You can install Mutt from the repository of your respective Linux distribution.

Further Reading

Mutt home page
Mutt Wiki
Dave's .muttrc file

0 comments: