POSTS
Reading Mail with Mutt+IMAP+SMTP+Header Caching Notes
BlogI recently got a new computer and decided to set up Mutt locally on it. Here’s how to get to reading mail with Mutt in a way that supports HTML and multi-byte character sets. This is not a perfect HOWTO (especially in the mutt ./configure section), but should get you most of the way there.
Use Darwin Ports
- sudo port install rxvt-unicode
- sudo port install tokyocabinet (if you’re going to talk to an IMAP host and want to cache the data, you need a db to cache into)
- sudo port install w3m (for displaying HTML mail)
Set up your shell to help mutt with multibyte
export LC_CTYPE="en_US.ISO-8859-1"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/local/lib
Build the source, don’t use port here
- Download mutt source (developer branch to get SMTP support, header caching, i.e. the good stuff)
./configure --prefix=/opt/local
--enable-imap --enable-smtp --enable-hcache
--with-tokyocabinet=/opt/local/
--with-curses=/opt/local/include/ncursesw/ --with-regex
- That means: target to install in /opt/local/bin, enable IMAP and SMTP support, enable IMAP header caching using the tokyocabinet libraries, use the wide Ncurses library so that we can show fancy characters in the terminal, and add regex support
- make && sudo make install
Make mutt take advantage of your configuration
set folder= {mailserver}INBOX # where i keep my mailboxes
set spoolfile={mailserver}INBOX # where my new mail is located
set imap_user=me # your user id
header_cache=$HOME/.muttconfig/.cache
set smtp_url="smtp://smtp.server"
auto_view text/html
Configure your .mailcap so that you automatically view HTML mail properly
# HTML
text/html; w3m -I %{charset} -dump %s; nametemplate=%s.html; copiousoutput
## Images
image/jpeg; open %s; nametemplate=%s.jpg; copiousoutput
image/png; open %s; nametemplate=%s.png; copiousoutput
image/gif; open %s; nametemplate=%s.gif; copiousoutput
image/bmp; open %s; nametemplate=%s.bmp; copiousoutput
# PDF
application/pdf; open %s pdf