How to use isync and the dovecot mail server to read your Gmail in Emacs efficiently

I have been using using Sacha Chua’s how to on using offlineimap and dovecot several times. But when I bought my latest notebook I wasn’t able to get offlineimap up and running. I’m currently using mbsync. Which is much faster and easier to configure.

I’m using ArchLinux but you should be able to adapt this guide on any other Linux distribution.

Install and configure isync

yaourt -S isync

The isync configuration file is named .mbsyncrc

edit ~/.mbsyncrc
IMAPAccount gmail
# Address to connect to
#Pass ***************
# To store the password in an encrypted file use PassCmd instead of Pass
#PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.mailpass.gpg"
# Use SSL
UseIMAPS yes
# The following line should work. If get certificate errors, uncomment the two following lines and read the "Troubleshooting" section.
CertificateFile /etc/ssl/certs/ca-certificates.crt
#CertificateFile ~/.cert/
#CertificateFile ~/.cert/Equifax_Secure_CA.pem

IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
# The trailing "/" is important
Path ~/mail/
Inbox ~/mail/Inbox

Channel gmail
Master :gmail-remote:
Slave :gmail-local:
# Exclude everything under the internal [Gmail] folder, except the interesting folders
Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"
# Or include everything
#Patterns *
# Automatically create missing mailboxes, both locally and on the server
Create Both
# Save the synchronization state files in the relevant directory
SyncState *

Edit the password and you are done.

Create the folders for your mail

mkdir -p ~/mail/Inbox

Install and configure dovecot

Install dovecot

pacman -S dovecot

Edit the main configuration file for dovecot

edit /etc/dovecot/dovecot.conf and set these lines:

protocols = imap

listen = *, ::

edit /etc/dovecot/conf.d/10-auth.conf and set these lines:

auth_mechanisms = plain

passdb {
args = /etc/dovecot/passwd
driver = passwd-file

!include auth-system.conf.ext

edit /etc/dovecot/conf.d/10-mail.conf and set these lines:

mail_location = maildir:/home/me/mail/Inbox/

namespace inbox {

inbox = yes


start dovecot

systemctl start dovecot
systemctl enable dovecot

initial sync

start the initial sync


mbsync -a

and look at output and wait. Isync is faster than offlineimap but the initial sync will still take some time.

create a cronjob for syncing

fcrontab -e

@ 10 /usr/bin/mbsync -a

configure gnus

edit ~/.gnus

(setq gnus-select-method
'(nnimap "Mail"
(nnimap-address "localhost")
(nnimap-stream network)
(nnimap-authenticator login)
(nnir-search-engine imap)))

(setq user-mail-address “”)
(setq gnus-ignored-from-addresses “”)

; set gmail smtp
(setq message-send-mail-function ‘smtpmail-send-it
smtpmail-starttls-credentials ‘((“” 587 nil nil))
smtpmail-auth-credentials ‘((“” 587 “” nil))
smtpmail-default-smtp-server “”
smtpmail-smtp-server “”
smtpmail-smtp-service 587)
;      smtpmail-local-domain “”)

and you are done.

access your emails in gnus

This is from Sacha Chuas blog:

Start Emacs. Start Gnus with M-x gnus. If you don’t see the INBOX group, press ^ (gnus-group-enter-server-mode), open nnimap:Mail, move your cursor to the INBOX, and either press RET to go into the group or press u (gnus-browse-unsubscribe-current-group) to toggle the subscription status until you’re subscribed to the group.

Have fun!

About these ads

One thought on “How to use isync and the dovecot mail server to read your Gmail in Emacs efficiently

  1. Pingback: isync: Because the cloud is unreliable | Inconsolation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s