Skip to content

Instantly share code, notes, and snippets.

@MatthewZMD
Last active March 27, 2024 00:46
Show Gist options
  • Save MatthewZMD/39cc00260486d17450f7228a4f36891f to your computer and use it in GitHub Desktop.
Save MatthewZMD/39cc00260486d17450f7228a4f36891f to your computer and use it in GitHub Desktop.
Gmail .mbsyncrc Sample
# mbsyncrc based on
# http://www.ict4g.net/adolfo/notes/2014/12/27/EmacsIMAP.html
# ACCOUNT INFORMATION
IMAPAccount gmail
# Address to connect to
Host imap.gmail.com
User <EMAIL_HERE>
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.emacs.d/mu4e/.mbsyncpass-<EMAIL_HERE>.gpg"
AuthMechs LOGIN
SSLType IMAPS
SSLVersions TLSv1.3
CertificateFile /etc/ssl/certs/ca-certificates.crt
# THEN WE SPECIFY THE LOCAL AND REMOTE STORAGE
# - THE REMOTE STORAGE IS WHERE WE GET THE MAIL FROM (E.G., THE
# SPECIFICATION OF AN IMAP ACCOUNT)
# - THE LOCAL STORAGE IS WHERE WE STORE THE EMAIL ON OUR COMPUTER
# REMOTE STORAGE (USE THE IMAP ACCOUNT SPECIFIED ABOVE)
IMAPStore gmail-remote
Account gmail
# LOCAL STORAGE (CREATE DIRECTORIES with mkdir -p ~/Maildir/gmail)
MaildirStore gmail-local
Path ~/Maildir/gmail/
Inbox ~/Maildir/gmail/INBOX
# REQUIRED ONLY IF YOU WANT TO DOWNLOAD ALL SUBFOLDERS; SYNCING SLOWS DOWN
# SubFolders Verbatim
# CONNECTIONS SPECIFY LINKS BETWEEN REMOTE AND LOCAL FOLDERS
#
# CONNECTIONS ARE SPECIFIED USING PATTERNS, WHICH MATCH REMOTE MAIl
# FOLDERS. SOME COMMONLY USED PATTERS INCLUDE:
#
# 1 "*" TO MATCH EVERYTHING
# 2 "!DIR" TO EXCLUDE "DIR"
# 3 "DIR" TO MATCH DIR
Channel gmail-inbox
Far :gmail-remote:
Near :gmail-local:
Patterns "INBOX"
Create Both
Expunge Both
SyncState *
Channel gmail-sent
Far :gmail-remote:"[Gmail]/Sent Mail"
Near :gmail-local:"Sent Mail"
Create Both
Expunge Both
SyncState *
Channel gmail-all
Far :gmail-remote:"[Gmail]/All Mail"
Near :gmail-local:"All Mail"
Create Both
Expunge Both
SyncState *
Channel gmail-starred
Far :gmail-remote:"[Gmail]/Starred"
Near :gmail-local:"Starred"
Create Both
Expunge Both
SyncState *
Channel gmail-trash
Far :gmail-remote:"[Gmail]/Trash"
Near :gmail-local:"Trash"
Create Both
Expunge Both
SyncState *
# GROUPS PUT TOGETHER CHANNELS, SO THAT WE CAN INVOKE
# MBSYNC ON A GROUP TO SYNC ALL CHANNELS
#
# FOR INSTANCE: "mbsync gmail" GETS MAIL FROM
# "gmail-inbox", "gmail-sent", and "gmail-trash"
#
Group gmail
Channel gmail-inbox
Channel gmail-sent
Channel gmail-trash
Channel gmail-all
Channel gmail-starred
@MatthewZMD
Copy link
Author

MatthewZMD commented Dec 4, 2019

Change <EMAIL_HERE> to your actual Gmail username.

Save your Gmail password at ~/.emacs.d/mu4e/.mbsyncpass-<EMAIL_HERE>

Encrypt it with

gpg2 -c ./.mbsyncpass-<EMAIL_HERE>

Delete the original plain password file for obvious security reasons.

@MatthewZMD
Copy link
Author

Set SSLVersions depending on the output of

openssl s_client -connect imap.gmail.com:993 -showcerts | grep Protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment