Mutt for (G)mail

I use kubuntu on a laptop which is new, but cheap. I am satisfied with my laptop but battery is an issue. My goal was to use my 450 euros laptop for 3 or more hours, which led me to change KDE and move towards more light applications. Now, I use the i3 window manager and mainly console applications.

I will be a liar if I said that battery usage was the motivation. No. I prefer minimalism. Thus, I try to find ways to use the terminal more and more. And that led me to mutt.

Mutt is text based email client. OK, good. What do I want from it? Well, to read emails and send emails and something a bit more:  to have an experience as close to a browser as possible. It might be not clear what I mean now, but it will be later on. Why Mutt? Well, searching online made it obvious that mutt is one of the best email clients out there and, as we all know, whatever you read online *must* be true.

I installed mutt the usually way, from the repositories.

sudo apt-get install mutt

While installing I was prompt with choosing (how was it called now?).. lets call it a usage profile. I did what every experienced hacker would recommend: choose the default. 🙂

I run it by typing ‘mutt’ in the terminal and, as expected, nothing happened. So, I started looking for a .muttrc file. There was not any. I created it in my home folder:

touch .muttrc

You could also create it in the “.mutt” folder. Mutt will check first the home folder and if it does not find it’s rc file, then he will check the it’s folder.

As the title implies, I want to use mutt for gmail. The muttrc files i was finding were quite easy to read, the syntax is almost self-explanatory. Still, writing one from scratch might not be what you want, so after checking online, I found this. Forget the website itself, or that it says that it is about ubuntu: we are talking about the rc file.

Copy pasting the muttrc file he recommends worked for me. Almost.

Of course, you need to fill the necessary fields with your own data (duh!): email address, password, maybe editor of choice. Now, writing the password in a text file is not really nice, is it? You have two choices:

  1.  Write your password in the text file. As a result, mutt will connect automatically. But, then you must either encrypt your password or change permissions of the file so no other user can open it, besides you. For the first option, this seems like a good way, though I haven’t tried it. For the second:
    chmod 600 .muttrc

    Here are some things about chmod.

  2. Do not write your password in the text file:). This means that every time you run mutt, you must provide your password, which will have an effect for the whole session.

I did the necessary and very, very complicated changes and i tried to login. Nah, login failed. Looked around muttrc, tried again as if something might have changed (who knows, maybe my machine is a non-deterministic turing machine), but nada, zero, failed.

My problem was that I copied from the website. As a result I had single quotes instead of double ones. This ->”<- is what I needed. Stupid? Oh yeah. Find and replace and I was done. Tried again…success!! But, until i find the problem, I realised that there were other reasons as well that might cause it:. The first thing was google permissions, the second the 2-step verification. In case you have similar issues, check those two settings. The first one is called “Access for less secure apps”. The second, well, “2-step verification”. As far as I saw, mutt cannot deal with the 2-step verification, so activating access for less secure apps and deactivating 2-step verification might solve your mutt issue, but think twice if its worth it just for using mutt.

Another issue I had was with this line:

macro index,pager d "<enter-command>set trash="imaps://[GMail]/Bin" <delete-message>" "Gmail delete message"

which I replaced with:

macro index,pager d "<enter-command>set trash=\"imaps://[Gmail]/Bin\"\n <delete-message>" "Gmail delete message"

Terminal application without colours? No way! Add the following to your .muttrc and change it to fit your taste:

# Colors
color hdrdefault cyan default
color attachment yellow default
color header brightyellow default "From: "
color header brightyellow default "Subject: "
color header brightyellow default "Date: "
color quoted green default
color quoted1 cyan default
color quoted2 green default
color quoted3 cyan default
color error red default # error messages
color message white default # message informational messages
color indicator white red # indicator for the "current message"
color status white blue # status lines in the folder index sed for the mini-help line
color tree red default # the "tree" display of threads within the folder index
color search white blue # search matches found with search within the internal pager
color markers red default # The markers indicate a wrapped line
color index yellow default '~O'
color index yellow default '~N'
color index brightred default '~F' # Flagged Messages are important!
color index blue default '~D' # Deleted Mails - use dark color as these are already "dealt with"
# identifies email addresses
color body brightred black [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+ # identifies URLs
color body brightblue black (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+

You can also follow Arch’s way. One thing here: arch’s wiki is a treasure which if hidden will make us all pirates capable of killing to get it. Respect to arch’s users!


Mr. Aitomatik

ps: in my gmail I have labels (or otherwise called tags, or tabs). Unfortunately, I haven’t found a way (yet!) to have them showing up in mutt… so mutt’s configuration was partly successful. Damn..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s