User Tools

Site Tools


software:cli:mail:sync

Introduction

Tired of having mails everywhere and use different software/interface to access them and bloated email client, i will use command line software to retrieve/filter, compose/read& send emails with fast and powerfull CLI. First we need to retrieve emails, there are lots of software doing this. I choose isync as it works out of the box for Gmail accounts :)

Pre-requisite

You need to enable IMAP connection on your gmail account: Setttings(button)/Settings/Forwarding and POP/IMAP then “enable IMAP”

Install

You need to install isync

Configuration

I use to store mails in the following folder hierarchy:

/home/warnaud/Mails/
└── superaddress1@gmail.com
└── superaddress2@gmail.com
└── superaddress3@gmail.com
└── …

This way all my mails from all my accounts will be synchronized in one place :) thus easily browsable/searchable. for configuration:

.mbsyncrc

The configuration file that will contains all nice email address to retrieve/sync

IMAPAccount gmail
# Address to connect to
Host imap.gmail.com
User superaddress1@gmail.com
Pass YourSup3rP@ssw0rd
#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
SSLType IMAPS
# 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/imap.gmail.com.pem
#CertificateFile ~/.cert/Equifax_Secure_CA.pem
 
IMAPStore gmail-remote
Account gmail
 
MaildirStore gmail-local
# The trailing "/" is important
Path ~/Mails/superaddress1@gmail.com/
Inbox ~/Mails/superaddress1@gmail.com/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 *

Sync

now we can test if it works:

mbsync gmail

depending on the size of your mailbox you better go grab a coffee :) you can also, and I would recommend it, filter you email prior to sync:filter Once all this is done you can switch to Mutt/neomutt

Reference

software/cli/mail/sync.txt · Last modified: 2021/12/29 21:09 by warnaud