Many of you must be knowing about it, would have been using it and the people who have used this they know how addictive and whimsical, this thing is. For those who haven’t listened about it or just have listened someone just mumbling about it, I have created this piece of manual or rather say learn-play sheet for you. If you like to learn and play in Linux and haven’t yet played with MUTT, this is for you.
Before all that fun and learn I want to explain the concept of mail and general email-flow concept.
What is MUTT?
We all know various mail services and we are using them like our organ. Now can’t live without them literally. That is why we are extending them to our life. That is the reason Blackberry got famous because of their exclusive mail service blended in it; more providers came into play, they also tried to extend it to mobiles not exactly like Blackberry but in their own ways. Now every smart phone has Mail app. Mails are an essential component of our life now. Most prominent of them Gmail/Yahoo/Hotmail etc are all available across the cloud.
Now when we say mailclient, they are the one which organize those mails and let you arrange /store and read them according to your own preferences. You use them, some of the popular ones are: Mozilla Thunderbird, Microsoft office Outlook and Outlook Express and the one which is topic of this article MUTT. So now it is clear that mutt is an email client or what we say MUA(Mail User Agent).
These are following protocols used for mail purpose:
- IMAP4(Most recent one in the list)
IMAP4 replaced POP3 in business. IMAP4 is better/faster/lighter and more proper than POP3 so it got over POP3 in maximum mail services. IMPA4 and POP3 is for incoming. Ports defined for IMAP4 is 993, where it is 995 for POP3. SMTP is used for outgoing and port for it is 465. HTTP is not only dedicated to email services but it is used for accessing mailboxes. Secured version is used, so port is 443.
MAIL Components Explained:
MUA,MTA, MDA and MRA are involved in a ideal mailflow process. Now what are they I just give them here a brief intro and explain them by the process of email flow.
MUA(Mail User Agent): It is the client program in which the user sends and receives mail. It may use scripts to complete its actions. It can be highly configurable like we do have MUTT. For instance for explaining one can configure text editors or word processors of its own choice for writing the email. Various other Linux MUAs are kmail, evolution, sylpheed, mulberry, pegasus, pine and elm.
MTA(Mail Transfer Agent): They are the one which receive envelopes from MUA and send, receive and route them accordingly. MTA don’t read headers they just see if the envelopes can be delivered to mailboxes. MTAs are vital components they don’t just send it ahead. But they decide whether emails are valid and can be moved ahead or not, if it contains error mail is sent back to user. It also acts SPAM FILTER for mail services. MTAs test the emails against a certain blacklist which they have. So they are not just transfer agent, they are smart agent. MTA uses SMTP for talking. Some of the popular MTAs for the job are sendmail, qmail, exim and postfix.
MDA(Mail Delivery Agent): They take mail from MTA and do the actual delivery plus filtering which may actually include many functions like virus detection, sorting and automatic answering.
Maildrop and procmail are MDAs.
MRA(Mail Retrieval Agent): MDA transfer mail to Mailbox. MRA fetch them from mailbox and then delivers to MUA. Some of them are fetchmail, getmail and retchmail.
Now I chain up them in a flow how they act in a mailflow process:
Email starts form a user who write it at MUA. MUA provides various options through programs and scripts. It may also contain security and encryption options . The finished mail in form of Envelope transfers to MTA. MTA receives envelope and irrespective of message inside validates it. If message is proper, routes it ahead in internet cloud and if it is invalid, then it is reflected back to user with error message. Mail is checked against SPAM blacklist and validated and is forwarded to MTA. Please note if it is special mail service or dedicated mail service MUA can directly send it to receiving MTA bypassing internet. MTAs uses SMTP.
MDA receives mail from MTA and they do filtering process which include sorting according to various parameters and virus protection or may include auto-answering options. MDA delivers them to mailboxes. Then MRA fetches these mails from mailboxes using IMAP4 or POP3 and transfers them to MUA.
Now coming over to our very own MUTT, we know MUTT is MUA. It uses sendmail as MTA in our case.
Some of the key features of MUTT which makes it special are:
- Its own configurable color setting. For messages, mailboxes and all.
- MIME support / PGP Support(Encryption/Signature)
- Support for multiple mailbox formats
- Keybindings and macros( They are superb. Easily they are one of the best feature of MUTT. You say the action and give and do any key binding for it.)
- Searches using regular expressions, including an internal pattern matching language
- It has .****rc configuration files for various setups of it, which are easy to edit and maintain.
Despite of them all it have all other regular features.
MUTT is text based because its developers think this is where it should be because if it is terminal based , it makes it more powerful.
I used MUTT version 126.96.36.199 which with sendmail as its MTA on my Ubuntu 10.10. As common user like me, you do not use our own domain services and our own mailboxes like those organizations where MUTT is highly used. I tried to configure my Gmail accounts to play with MUTT. Yes you may also configure any mail accounts using SMTP and IMAP protocols. For this you may refer MUTT manuals.
Installing MUTT is stunningly easy.
On Debians(For others too you may find tutorials) just write:
#> apt-get install mutt
Reading package lists… Done
You may require the root login to install it and use it. It installs it in root directory. So if you want to access its files change to root directory after super user login where ~ indicates root home directory which is generally locked when accessing through GUI. Type:
Please remember that it creates a lot of hidden directories after installation starting with . In case you don’t know.
To see all directories and files you may see all of them by pressing:
MUTT directory content look like one below:
The most basic configuration file for MUTT is called .muttrc where . signifies it as hidden file. It is one power script which controls whole MUTT configuration. You may open it with any editor you want and add/remove and manipulate the stuff.
You may prepare your .muttrc file by having look on to sample .muttrc files. To give a glance I show my .muttrc file here( I am afraid of it though)
Please note that this is just a stub of .muttrc file. Whole content can’t be shown here.
To start MUTT you should have super user access or user with adequate privileges. Just type mutt from any space and it will be fire up.
Now configure your gmail account you may have to add following lines to your .muttrc file :
set imap_user = “email@example.com”
set imap_pass = “”
set folder = “imaps://imap.gmail.com:993″
set record=+[Gmail]/”Sent Mail”
set from = “firstname.lastname@example.org”
set realname = “yourname”
set smtp_url = “smtp://email@example.com:587/”
Please note you may use multiple accounts for incoming and outgoing mails and use Account-hook for that. If you just write down the multiple IDs in suppose incoming mails automatically the later in the queue will be opened by MUTT. I have used different incoming and outgoing IDs in my configuration. Please note I have kept the password blank because of security reason. If you don’t enter the corresponding password here you will be asked for it while you use it in MUTT.
Note that SMTP URL and IMAP URL are the corresponding address mailboxes of Google for incoming and outgoing.
But it’s not just that you want for activating Gmail in MUTT. You need various SSL security certificates for that. They can be added right from command line using apt-get just like other packages. Every time after initializing MUTT it installs these certificates and try to access the Gmail mailbox.
Following is the accessing a mailbox in progress
Below figure shows some functions for which generic binding can be done. Above shows the above in figure shows some the keys which have been keybounded.
Aliases can also be used in MUTT
An alias file needs to be created for the purpose where all the aliases are defined with their extensions. I use in this example s for firstname.lastname@example.org which I have defined in my aliases file.
Aliases file format is like:
alias b email@example.com
alias s firstname.lastname@example.org
alias sa email@example.com
Following in figure was the sa alias which was auto filled with EmaiID later.
The source for alias file need to be defined in .muttrc like :
Install Abook for simpler alias setting.
Just hit Ctrl A and if you have selected some mail it will let you to store alias for current email address. Or you can add more emails by accessing it through terminal. Abook is best phonebook integration for MUTT.
Following is an alias making in progress of LFY editor Aditya:
For integration of Abook you need to add following text in .muttrc file:
set query_command=”abook –mutt-query ‘%s’”
macro index,pager A “abook –add-email” “add the sender address to abook”
macro generic,index,pager \ca “abook” “launch abook”
We can use signatures in for which separate .signature file is needed.
Source for signature is defined like:
My signature looks like in light green in Gmail to which I have sent this mail. You may make it much beautiful than me.:
Please note that editor for writing mail is Nano. You may use any other editor for the purpose for this you just have to set another editor in .muttrc file like:
set editor=”emacs -nw”
Any file can be attached by simply attaching few options and giving path that too before even starting mutt.
root@tuxxxy:~# mutt -s “HI” -a “/home/tuxxxy/Desktop/jkhk”
-s is for subject
-a is for attachment file
Below in green is the attachment in mutt along with main message body attachment:
Beside these they are million options to configure MUTT.
Like below we can configure it supernumerary ways:
set timeout=60 #Check for mail every minute
That’s why it is known as the one of the most flexible MUA ever. To switch between various mailboxes you need to just press y.
The security and encryption are one of the most important aspects in today’s time. Security is to prevent your emails from intruders. There are various security techniques like public key , and asymmetric keys and various other you must be knowing. But the strongest out of them is PGP. PGP stands for Pretty Good Privacy. MUTT supports PGP for its mail services. I have used GPG here which is GnuPG.
Following is the key making in progress:
It is very hybrid approach to secure your mails. It uses symmetric-key cryptography for speed, and public-key cryptography with a session key to ensure maximum performance.
While mailing at the last step just before sending just press p and and it asks you what do you want to mail to be encrypted or signature or both.
Please note signature is necessary for the reason because it ensures that your mail is not manipulated in-between. By decrypting the sent signature which is sent along mail file it can be decrypted to the date and email id attached to it. For that you have to use the signature file as input in format .asc or .sig.
As I show you the mail in which I used signature. Signature file comes along with mail in a file signature.asc which user can use to verify mail.
Similarly press E for encryption and you will be asked for the keyID which you had generated after entering your mail will be encrypted.
Use gpg –list-keys to list your all of keys which you have made.
These were the few of things which you can do while playing with MUTT, but please note that this is not the end to possibilities for MUTT. MUTT gives you that much space to play that neither I can cover all of them here, nor I have learnt all of them. Try using it and you will explore yourself and you may share with us all so that we can also learn.
So give wings to your excellence and let them flutter in the sky of LINUX.