Team LiB
Previous Section Next Section

Hack 54. View Word and PDF Files from Within Mutt

Mutt is an extremely powerful terminal-based email client that supports IMAP, POP, and much more. No graphical email client can come close to the configurability of Mutt. That's why a lot of hard-core Linux users still use Mutt in spite of the myriad GUI-based email clients.

It is certainly possible to launch a GUI application such as or Acrobat Reader to view Word and PDF email attachments in Mutt. But Mutt users aren't always using a graphical desktop, so it's handy to be able to view these documents as text, right inside the message itself.

Here's how to do it. First, you need to edit the Mutt configuration file. The default configuration file is usually /etc/Muttrc, but you'll most likely want to create your own even if you do it by copying the default and modifying it. Mutt lets you define your user configuration file as either ~/.muttrc or ~/.mutt/muttrc. Modify your personal Mutt configuration file to point to a custom mailcap file. For example:

set mailcap_path="~/mailcap.mutt"

Then edit the ~/mailcap.mutt file to include these two lines:

application/pdf; pdftohtml -q -stdout %s | w3m -T text/html; copiousoutput

application/msword; wvWare -x /usr/lib/wv/wvHtml.xml %s 2>/dev/null | w3m -T text/html; 

Now all attached PDF and Microsoft Word documents will appear within the text of the email. Granted, the formatting isn't as pretty as when you view Word or PDF documents [Hack#52] and [Hack#53], because all the output is piped into Mutt's own display, and not in a specialized pager, such as elinks or w3m. But you can still read the content of the attached file. And if it interests you enough to read it in a better format, you can save the file and read it with whatever program you wantincluding one of the scripts in the previously mentioned hacks.

    Team LiB
    Previous Section Next Section