Offlineimap + mutt + gmail + msmtp = crazy delicious email

I’ve finally settled on the best email setup I’ve had since the fetchmail+procmail+mutt setup I used several years ago. It’s not much different and still allows me to use my absolute favorite email client, mutt. “Offlineimap is a tool to simplify your email reading” says the homepage for this deceptively simple program. With offlineimap I now have a backup of all the messages in my gmail account, mutt performance is improved (it’s much better at Maildir than direct imap access), and have synchronized my mail reading on 3 different machines.

So here’s the basics.

.offlineimaprc:

[general]
metadata = ~/.offlineimap
accounts = GmailMain
ui = Noninteractive.Quiet
 
[mbnames]
enabled = yes
filename = ~/.mutt/muttrc.mailboxes
header = "mailboxes "
peritem = =%(foldername)s
sep = " "
footer = "\n"
 
[Account GmailMain]
localrepository = GmailLocal
remoterepository = GmailRemote
 
[Repository GmailLocal]
type = Maildir
localfolders = ~/.mail/GMAIL
 
[Repository GmailRemote]
type = Gmail
remoteuser = yourname@gmail.com
remotepassfile = ~/.mailpass

.msmtprc:

account default
host smtp.gmail.com
port 587
from yourname@gmail.com
tls on
tls_starttls on
# you can google on how to find this
tls_trust_file /home/webframp/.mutt/certs/Thawte_Premium_Server_CA.pem
auth on
user yourname
password yourpassword
logfile ~/.msmtp.log

relevant bits of .muttrc:

set mbox_type=Maildir                                   # mailbox type
set hostname=gmail.com                                  # This is my domain.
 
# GMAIL+OFFLINEIMAP settings
set imap_user=sean.escriva@gmail.com
set folder=$HOME/.mail/GMAIL
set spoolfile=+/INBOX
set postponed="+[GMAIL].Drafts"
set record="+[GMAIL].Sent Mail"
 
# Mailboxes via offlineimap
source $HOME/.mutt/muttrc.mailboxes
 
set sendmail="/usr/bin/msmtp"               # Sendmail alternative

I find running offlineimap via my crontab provides a nice solution to that
compulsive mail check impulse that can easily develop. Of course I also have a
Maildir check in my dzen xmonad statusbar using the ppExtras setting of my
pretty printer:

...
  , ppExtras = [logMail]
  }
where
 logMail = dzenColorL colorPink "" . wrapL mailIcon "". padL $ maildirNew mailDir
 mailIcon = "^i(/home/webframp/.dzen/icons/dzen_bitmaps/envelope.xbm)"
 mailDir = "/home/webframp/.mail/GMAIL/INBOX"

Maybe you can glean something useful from my setup

Post a Comment

Your email is never published nor shared. Required fields are marked *