Using mutt email client to check mail


What is Mutt?

Mutt is a command line based Email client. It’s a very useful and powerful tool to send and read mails from command line in Unix based systems. Mutt also supports POP and IMAP protocols for receiving mails. It opens with a coloured interface to send Email which makes it user friendly to send emails from command line.

Features
  • Its very Easy to install and configure.
  • Allows us to send emails with attachments from the command line.
  • It also has the features to add BCC (Blind carbon copy) and CC (Carbon copy) while sending mails.
  • It allows message threading.
  • It provides us the facility of mailing lists.
  • It also support so many mailbox formats like maildir, mbox, MH and MMDF.
  • Supports at least 20 languages.
  • It also support DSN (Delivery Status Notification).

1. INSTALLATION

- Ubuntu/Debian
apt-get install mutt
- Fedora/CentOS
yum install mutt

2. CONFIGURATION

2.1. Configuring for an account mail


Create
mkdir -p ~/.mutt/cache/headers mkdir ~/.mutt/cache/bodies touch ~/.mutt/certificates
Create mutt configuration file muttrc
touch ~/.mutt/muttrc
Open muttrc
vim ~/.mutt/muttrc
Add following configurations
set ssl_starttls=yes
set ssl_force_tls=yes
set imap_user = 'account@gmail.com'
set imap_pass = 'PASSWORD'
set from='account@gmail.com'
set realname='Your Name'
set folder = imaps://imap.gmail.com:993/
set spoolfile = imaps://imap.gmail.com/INBOX
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set smtp_url = 'smtps://smtp.gmail.com:587/'
set move = no
set imap_keepalive = 900

2.2. Configuring for multiple account mail

Instructions directories and files
~/
|── .mutt/
|   ├── account.com.gmail.foo
|   ├── account.com.gmail.bar
|   ├── com.gmail.foo/
|   └── com.gmail.bar/
└── .muttrc


~/.muttrc
# Folder hooks
folder-hook 'account.com.gmail.foo' 'source ~/.mutt/account.com.gmail.foo'
folder-hook 'account.com.outlook.bar' 'source ~/.mutt/account.com.outlook.bar'
# Default account
source ~/.mutt/account.com.gmail.foo
# Macros for switching accounts
macro index 'source ~/.mutt/account.com.gmail.foo!'
macro index 'source ~/.mutt/account.com.outlook.bar!'
# Fetch mail shortcut
bind index G imap-fetch-mail

~/.mutt/account.com.gmail.foo
set imap_user = "foo@gmail.com"
set imap_pass = ""
set smtp_url = "smtp://foo@smtp.gmail.com:587/"
set smtp_pass = ""
set from = "foo@gmail.com"
set realname = "Foo"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set header_cache = ~/.mutt/com.gmail.foo/cache/headers
set message_cachedir = ~/.mutt/com.gmail.foo/cache/bodies
set certificate_file = ~/.mutt/com.gmail.foo/certificates

~/.mutt/account.com.outlook.bar
set imap_user = "bar@outlook.com"
set imap_pass = ""
set smtp_url = "smtp://bar@smtp-mail.outlook.com:587/"
set smtp_pass = ""
set from = "bar@outlook.com"
set realname = "Bar"
set folder = "imaps://imap-mail.outlook.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set header_cache = ~/.mutt/com.gmail.bar/cache/headers
set message_cachedir = ~/.mutt/com.outlook.bar/cache/bodies
set certificate_file = ~/.mutt/com.outlook.bar/certificates

3. USAGE

- Read mail:
$ mutt
- Send mail:
$ mutt -s "Subject of mail" -c -b mail address of recipient
- Send mail with attach file
$ mutt  -s "Subject of Mail" -a -c   mail address of recipient

- Getting help
$ mutt -h
Mutt 1.4.2.2i (2006-07-14)
usage: mutt [ -nRyzZ ] [ -e ] [ -F ] [ -m ] [ -f ]
mutt [ -nx ] [ -e ] [ -a ] [ -F ] [ -H ]
mutt [ -i ] [ -s ] [ -b ] [ -c ] [ ... ]
mutt [ -n ] [ -e ] [ -F ] -p -v[v]
options:
-a      attach a file to the message
-b
  specify a blind carbon-copy (BCC) address
-c
  specify a carbon-copy (CC) address
-e   specify a command to be executed after initialization
-f      specify which mailbox to read
-F      specify an alternate muttrc file
-H      specify a draft file to read header from
-i      specify a file which Mutt should include in the reply
-m      specify a default mailbox type
-n            causes Mutt not to read the system Muttrc
-p            recall a postponed message
-R            mailbox in read-only mode
-s      specify a subject (must be in quotes if it has spaces)
-v            show version and compile-time definitions
-x            simulate the mailx send mode
-y            select a mailbox specified in your `mailboxes' list
-z            exit immediately if there are no messages in the mailbox
-Z            open the first folder with new message, exit immediately if none
-h            this help message