Setting up mutt for Gmail

emailgmailmutt

I am trying to set up mutt for Gmail. I am following Crunchbang wiki instructions, however, after putting

set from = "yourusername@gmail.com"
set realname = "Your Real Name"

set imap_user = "yourusername@gmail.com"
set imap_pass = "yourpassword"

(with my details, of course), I get

$ mutt
Error in $HOME/.muttrc, line 12: imap_user: unknown variable
Error in $HOME/.muttrc, line 13: imap_pass: unknown variable
source: errors in $HOME/.muttrc
Press any key to continue...

If I try to send an email, it doesn't work because instead of IMAP, it tries to send email directly from my localhost's mail system. Mutt says it is version Mutt 1.4.2.3i.

Update:

So I downloaded mutt-devel on Macports, which is 1.5:

$ mutt -v
Mutt 1.5.21 (2010-09-15)
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: Darwin 11.3.0 (x86_64)
ncurses: ncurses 5.9.20110404 (compiled with 5.9)
libiconv: 1.14
libidn: 1.22 (compiled with 1.22)
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/mail"
PKGDATADIR="/opt/local/share/mutt"
SYSCONFDIR="/opt/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/.

As it stands, it is not configured to use smtp, but imap should be enabled. However, just starting mutt hangs on

Connecting to gmail.com...

Is there a way to check the logs or something to see if, say it can't find the server or the password is being rejected or something else?

Update:

After installing for ssl, imap, and smtp support, I still get these warnings/errors, even though it can connect to gmail.

Error in $HOME/.muttrc line 9: trash: unknown variable
Error in $HOME/.muttrc, line 11: header_cache: unknown variable

Best Answer

First you can check is you mutt support IMAP and SMTP by exec
mutt -v

FLAG like +USE_IMAP and +USE_SMTP

if you want use IMAP ,in your muttrc must have

set imap_user = "YOUR.EMAIL@gmail.com"
set imap_pass = "PASSWORD" 
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX" 

If I try to send an email, it doesn't work because instead of IMAP, it tries to send email directly from my localhost's mail system

IMAP?
Maybe you wanted is SMTP

set smtp_url = "smtp://yourusername@smtp.gmail.com:587/"
set smtp_pass = "yourpassword"

or you can install external programs like esmtp or msmtp