Mailcap file for mail client mutt

Posted by Eric Scheibler at August 8, 2013

This article contains my mailcap file for the console mail client mutt. With the defined rules in the file it's possible to open PDF, DOCX, HTML and other documents in mutt directly.

You must copy the mailcap file to the folder ~/.mutt and restart the mail client. After that you can open a mail attachment by navigating to the mail in the index view and pressing "v".

Download: mailcap

# mailcap file for mutt
# copy it to ~/.mutt/mailcap

# general hint
# find out unknown file extension mime type:
# in the mutt index view, go to the mail and press "|"
# then enter the command: grep Content-Type

# .pdf
# sudo aptitude install poppler-utils
application/pdf;            pdftotext -q -raw %s -; copiousoutput
application/vnd.fdf;        pdftotext -q -raw %s -; copiousoutput

# .html
# sudo aptitude install w3m
text/html;                  w3m %s; nametemplate=%s.html;

# microsoft office
# .docx (since Office 2010)
application/; cat %s | antiwordxp.rb; copiousoutput
application/vnd.openxmlformats-officedocument.wordprocessingml.document;  cat %s | antiwordxp.rb; copiousoutput

# .doc
# sudo aptitude install antiword
application/msword;         antiword %s; copiousoutput

# .xls
# sudo aptitude install catdoc
application/;      xls2csv -x %s -s cp1252 -d utf-8; copiousoutput

# .rtf
# sudo aptitude install unrtf
application/rtf;     unrtf --text %s; copiousoutput

# OpenOffice
# .odt
application/vnd.oasis.opendocument.text;    odt2txt --stdout %s; copiousoutput