From Pine View Farm

Email the Way It’s Meant To Be 0

I have lately been leaning my way around Mutt, a command line email client. It’s not my only email client–the one I use most is still Opera’s email client.

Mutt Inbox Interface

Mutt Inbox

I got there via a circuitous route. I want to improve my skills using vi and vim (“vi improved”). Vi or vim (sometimes both) are present in almost every Linux distribution and do not require a GUI to work.

Vi was developed in the days of 300-baud modems; it has a cryptic command set and no menu (though derivatives with menus do exist). Vi/vim’s help file is little more than a list of commands; using the program is the best way to learn it.

There are many excellent GUI editors such as Kate (my favorite GUI text editor) or Gedit, but they require a GUI to work. If you break your GUI, they are no good to you, but if you break your GUI, you can likely fix it with vi/vim. (Linux has many other command line text editors,* but vi/vim is the most powerful and versatile, once you understand it. Emacs is a special case; it’s not an editor, it’s an OS without a kernel.)

Mutt defaults to using vi/vim as its default editor, though you can configure it to use other editors if you wish. I figured that, if I set up an email client that would force me to use vi/vim, I’d learn more about them. I did and I have, though I’ve got a lot more to learn.

Mutt is not like Thunderbird or Outlook. It does not receive or send mail, it just reads it. For it to work, a suite of applications is needed.

  • An application to get the mail. (I used fetchmail, but there are many others.)
  • Applications to process the mail and put it where it belongs (I used procmail and formail).
  • An application to send the mail (I used msmtp, but, again, there are others).

I’m not going into the details of my configuration. Most of it was adapted directly from the internet. These two webpages enabled me to set up the basic configuration; they are clear and easy-to-follow:

This one showed me one way to manage multiple email accounts in Mutt (there are other ways that I intend to explore):

Once I decided to set Mutt up, I found that it was not nearly so complicated as I had feared and that there was a lot of help out there in the inner tubes.

Here are some screenshots.

Reading a Email in Mutt

Reading a Email in Mutt

Composing an Email in Mutt Using the Vim Editor

Composing an Email in Mutt Using the Vim Editor

Email Ready To Send

Email Ready To Send.
Note that the actual body of the email is considered an “attachment.:”

HTML email presents a special problem (in addition to being inherently evil). Here is a raw HTML email:

Raw HTML Email

Raw HTML Email

To turn that muck into something readable, it must be pumped through a browser. You can do that by configuring a .mailcap file (the “dot” that precedes the file name makes it a hidden file). There are many text browsers to choose from: links, elinks, lynx, w3m are the most popular. I used links, because it came with Slackware, which is installed to the computer on which I am writing this.

Here’s my mailcap file (you can add additional lines to it for additional functions, for example, to manage image files).

    text/html; links %s; nametemplate=%s.html
    text/html; links -dump %s; nametemplate=%s.html; copiousoutput

This same email was shown above in the image captioned “Reading a Email in Mutt.”

Opening links embedded in emails requires yet another application. I used urlview; in the Mutt configuration file (.muttrc), you tell Mutt to use urlview to extract the URLs.

    # simulate the old url menu
    macro index \cb |urlview\n 'call urlview to extract URLs out of a message'
    macro pager \cb |urlview\n 'call urlview to extract URLs out of a message'

Here is a list of URLs in an email, as revealed by urlview:

URLs extracted from an email with urlview

URLs extracted from an email with urlview

Move the cursor to the URL you wish to open and hit enter twice. It will open in the browser specified in your .urlview file. I told mine to use Opera.

    COMMAND opera %s

One last thought: The colors in the configuration at the Gentoo wiki had white text on a blue background. I found them difficult to read in bad light. I changed them to put black text on a white background (though the “white” is more like “gray”), and made several other minor changes because of the “white” background. Here is the relevant section from my .muttrc file; you can compare it to the one at the Gentoo site.

    color hdrdefault brightcyan white
    color header brightwhite white "^from:"
    color header brightwhite white "^subject:"

    color quoted brightgreen white
    color signature black white

    color indicator blue green

    color error brightyellow white
    mono error bold
    color status black cyan
    mono status bold
    color tree yellow white

    color tilde brightmagenta blue
    color body black white "[-a-z_0-9.]+@[-a-z_0-9.]+"
    mono body bold "[-a-z_0-9.]+@[-a-z_0-9.]+"
    color body brightyellow black "^Good signature"
    mono body bold "^Good signature"
    color body brightwhite red "^Bad signature from.*"
    mono body bold "^Bad signature from.*"
    color normal black white
    color message green white
    color attachment brightgreen blue

_____________

*Technically, these are not “command line text editors,” but text editors which run from the command line. Sed is a command line text editor, in that you edit files directly from the command line. I do not know how to use sed; I know only that it exists.

Share

Comments are closed.