software

Syncing email locally

2 min read

To sync our email from the service provider to our computer, we can use an email client such as Thunderbird or any of the many others available.

But if we want, for example, to read our email with mutt (even offline), or to make an archive / backup of our email, we can use offlineimap.

On Ubuntu and derived distributions, just install offlineimap with the command

text
sudo apt install offlineimap

We can create a file called .offlineimaprc in the home folder with the following content:

text
[general]
accounts = MyAccount

maxsyncaccounts = 1

[Account MyAccount]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/Mail/

[Repository RemoteOld]
type = IMAP
remotehost = <server ip/address>
remoteuser = <remote user>
remotepass = <remote user password>
ssl = yes
#ssl_cert_verify = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
#readonly = true

Some remarks about the options used.

text
readonly = true

We use this option to make sure the sync only goes from the server to the local folder.

text
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

Used on a Pop_OS! installation, but equally valid for Ubuntu 22.04. If you use another distribution, check where it keeps its certificates.

Once the file is configured with your details, you just need to run offlineimap and wait for it to finish.

text
offlineimap

For more information you can always visit the project website at https://www.offlineimap.org/

Photo by Daria Nepriakhina 🇺🇦 on Unsplash

#email#imap#linux#offlineimap