Friday, June 1, 2012

mutt for gmail on cygwin

I wanted to set up mutt to check my gmail and google apps accounts on cygwin and it took a bit of trial and error, since the default mutt build in cygwin isn't configured appropriately for this setup. I installed mutt using cygwin's setup.exe, then went searching for configuration examples. The best starting point I found was the following:

http://lifehacker.com/5574557/how-to-use-the-fast-and-powerful-mutt-email-client-with-gmail

This site gives some instructions along with a sample .muttrc:

# A basic .muttrc for use with Gmail

# Change the following six lines to match your Gmail account details
set imap_user = "YOUR.EMAIL@gmail.com"
set imap_pass = "PASSWORD"
set smtp_url = "smtp://YOUR.EMAIL@smtp.gmail.com:587/"
set smtp_pass = "PASSWORD"
set from = "YOUR.EMAIL@gmail.com"
set realname = "YOUR NAME"

# Change the following line to a different editor you prefer.
set editor = "nano"

# Basic config, you can leave this as is
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set imap_check_subscribed
set hostname = gmail.com
set mail_check = 120
set timeout = 300
set imap_keepalive = 300
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor complete-query
bind editor ^T complete
bind editor noop

# Gmail-style keyboard shortcuts
macro index,pager y "unset trash\n " "Gmail archive message"
macro index,pager d "set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n " "Gmail delete message"
macro index,pager gi "=INBOX" "Go to inbox"
macro index,pager ga "=[Gmail]/All Mail" "Go to all mail"
macro index,pager gs "=[Gmail]/Starred" "Go to starred messages"
macro index,pager gd "=[Gmail]/Drafts" "Go to drafts"

I copied this to my home directory, made the appropriate changes, ran mutt, and then began reading ensuing the error messages...

$ /usr/bin/mutt
Error in /home/peter/.muttrc, line 6: smtp_url: unknown variable
Illegal instruction (core dumped)

The first line was straightforward enough, so I commented that line out, re-ran mutt, commented out another line noted in the next error, and so on, but I quickly found that the stock mutt build isn't compiled with support for much:

$ /usr/bin/mutt -v
Mutt 1.5.20 (2009-12-10)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: CYGWIN_NT-6.1 1.7.15(0.260/5/3) (i686)
ncurses: ncurses 5.7.20091227 (compiled with 5.7)
libiconv: 1.13
hcache backend: GDBM version 1.8.3. 10/15/2002 (built Feb 26 2009 02:58:00)
Compile options:
-DOMAIN
-DEBUG
-HOMESPOOL -USE_SETGID -USE_DOTLOCK -DL_STANDALONE +USE_FCNTL -USE_FLOCK
+USE_POP +USE_IMAP -USE_SMTP
+USE_SSL_OPENSSL -USE_SSL_GNUTLS -USE_SASL -USE_GSS +HAVE_GETADDRINFO
+HAVE_REGCOMP +USE_GNU_REGEX
+HAVE_COLOR +HAVE_START_COLOR +HAVE_TYPEAHEAD +HAVE_BKGDSET
+HAVE_CURS_SET +HAVE_META +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP +CRYPT_BACKEND_CLASSIC_SMIME -CRYPT_BACKEND_GPGME
-EXACT_ADDRESS -SUN_ATTACHMENT
+ENABLE_NLS +LOCALES_HACK +HAVE_WC_FUNCS +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV -ICONV_NONTRANS -HAVE_LIBIDN +HAVE_GETSID +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="/var/spool/mail"
PKGDATADIR="/usr/share/mutt"
SYSCONFDIR="/etc"
EXECSHELL="/bin/sh"
-MIXMASTER
To contact the developers, please mail to mutt-dev@mutt.org.
To report a bug, please visit http://bugs.mutt.org/.
mutt-dev@mutt.org

No SMTP support is the big problem, so I knew right away that a rebuild was needed. I installed the mutt source package, which gave me the source tree in /usr/src/mutt-1.5.20-1/, but then there was the issue of configuring. Much to my display, I got errors when I even tried to run ./configure!

After a little more research I found that I needed to run the following command:

autoreconf -f -i -Wall,no-obsolete

Fortunately this worked and I could now proceed with the build. Here are the options I ended up needing:

./configure --enable-imap --enable-pop --with-ssl --enable-smtp --with-homespool=mailspool --enable-hcache --enable-debug --with-sasl

You can easily leave out --enable-debug, but I left this in to help with future troubleshooting. I also needed to install a couple packages through cygwin, though I regret that I didn't keep a list. If you use these instructions it would be nice if you could leave a comment noting what extra packages you needed to install.

After configure and a make install, I now have a working mutt at /usr/local/bin/mutt with the following options:

$ /usr/local/bin/mutt -v
Mutt 1.5.20 (2009-12-10)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: CYGWIN_NT-6.1 1.7.15(0.260/5/3) (i686)
ncurses: ncurses 5.7.20091227 (compiled with 5.7)
libiconv: 1.14
hcache backend: GDBM version 1.8.3. 10/15/2002 (built Feb 26 2009 02:58:00)
Compile options:
-DOMAIN
+DEBUG
+HOMESPOOL -USE_SETGID +USE_DOTLOCK -DL_STANDALONE +USE_FCNTL -USE_FLOCK
+USE_POP +USE_IMAP +USE_SMTP
+USE_SSL_OPENSSL -USE_SSL_GNUTLS +USE_SASL -USE_GSS +HAVE_GETADDRINFO
+HAVE_REGCOMP -USE_GNU_REGEX
+HAVE_COLOR +HAVE_START_COLOR +HAVE_TYPEAHEAD +HAVE_BKGDSET
+HAVE_CURS_SET +HAVE_META +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP +CRYPT_BACKEND_CLASSIC_SMIME -CRYPT_BACKEND_GPGME
-EXACT_ADDRESS -SUN_ATTACHMENT
+ENABLE_NLS -LOCALES_HACK +HAVE_WC_FUNCS +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV -ICONV_NONTRANS -HAVE_LIBIDN +HAVE_GETSID +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="mailspool"
PKGDATADIR="/usr/local/share/mutt"
SYSCONFDIR="/usr/local/etc"
EXECSHELL="/bin/sh"
-MIXMASTER
To contact the developers, please mail to mutt-dev@mutt.org.
To report a bug, please visit http://bugs.mutt.org/.
mutt-dev@mutt.org

Enjoy!