Mutt
Mutt rocks.
So I can really go into this, but quickly here is a configuration file you can alter. Remember if you don't save it as .muttrc you can still just use another method to invoke it.
Contents
Install mutt with cyrus-sasl + imap + ssl support
Linux: As if! - However, let me know if you have a distro and can't get it working within 30 minutes (devnull@cimmerii.org). I do look at it every now and then so be patient however for most Linux distros, this is easy to accomplish.
Mac OS X (macports):
$ sudo port install mutt-devel +headercache +imap +ssl
Preparing for mutt
You need to create a few directories and files. This setup is semi-taken from someone else but I saw reason in it. You can use mutts own powers to choose which config file to read. Anyways, more on that afterwards.
Create a .mutt directory in your home directory along with a header cache directory and the cache file
$ mkdir -p ~/.mutt/hcache $ touch ~/.mutt/hcache/fastmail
Create a muttrc file within the .mutt directory.
$ echo 'source ~/.mutt/muttrc.$CONFIG' >> ~/.mutt/muttrc
Actual email/gmail configuration file
Okay, so this file we save with a separate name such as
~/.mutt/muttrc.mygmail
or
~/.mutt/muttrc.your_username@gmail.com
Whatever you want to choose is up to you but the file should go into the .mutt directory. Just don't choose null or empty etc etc.
I will choose say your_username@gmail.com for example as such there should be a file here:
~/.mutt/muttrc.your_username@gmail.com
There is a usable (but in need of adjustment) configuration file below, however take note of the "set from", "set imap_user" and "set imap_pass" settings. If any of these have a dollar sign ($), you will need to either escape it or use single quotes.
########################################### # Basic mutt settings # Who the sender is (yes it does make sense) set from = "Your Name <your_username@gmail.com>" # How often to check for new mail in seconds set mail_check = 300 # header cache directory so you don't have to redownload everything each time (note: you need to ensure it exists) set header_cache = "~/.mutt/hcache/fastmail" # Don't mark unread messages as old on exit set mark_old = no # Place most recently received messages at the top (note: this means it uses the time your server received the e-mail and not the time the e-mail says it was sent) set sort = reverse-date-received # Do not collapse unread threads set collapse_unread = no # Do not ask me to move read messages (I prefer to do that myself) set move = no ########################################### # Basic gmail settings set imap_user = "your_username@gmail.com" set imap_pass = "your_password" ########################################### # IMAP settings set my_imap_server = "imap.gmail.com" ########################################### # SMTP (for gmail to work I needed cyrus-libsasl2) set smtp_url = "smtps://${imap_user}:${imap_pass}@smtp.gmail.com:465/" ########################################### # Mailboxes mailboxes "imaps://$my_imap_server/INBOX" set spoolfile = "imaps://$my_imap_server/INBOX" # Default inbox set folder = "imaps://$my_imap_server/" # Default location of mailboxes set postponed = "imaps://$my_imap_server/[Gmail]/Drafts" set record = "imaps://$my_imap_server/[Gmail]/Sent Mail"
How to use it
The reason why we are using a variable in the main muttrc configuration file is so you can use mutt for several accounts.
Now, to call mutt and tell it to use your gmail account you have to set an environment variable.
$ CONFIG="username@gmail.com" mutt
The reason this works is because in our ~/.mutt/muttrc file we tell it to
source ~/.mutt/muttrc.$CONFIG
. When the above command is ran, mutt then looks for
~/.mutt/muttrc.username@gmail.com
which exists and is sourced. Voila!
You can set an alias to make it easier in your shells profile / rc.
alias mygmail="CONFIG='USERNAME@GMAIL.COM' mutt"