emacs/mbsync

Prerequis

  • install mbsync/isync

on debian ubuntu like :

# apt install isync

mbsync configuration

Create folder to store your mails:

$ mkdir -p /localstorage/mbsync/authsmtp
$ ln -s /localstorage/mbsync/ ~/.localsyncmail

Create a .mbsyncrc file. I have it in my ~/.emacs.d/ directory.

IMAPAccount AuthSMTP
# Address to connect to
Host mail.authsmtp.com
User mypersonnallogin@authsmtp.com
PassCmd "gpg -q --for-your-eyes-only --no-tty -d ~/.emacs.d/.mbsyncpass.gpg"
#Pass ***************
# To store the password in an encrypted file use PassCmd instead of Pass
# PassCmd "gpg -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/mail.authsmtp.com.pem
#CertificateFile ~/.cert/imap.gmail.com.pem
#CertificateFile ~/.cert/Equifax_Secure_CA.pem

IMAPStore authsmtp-remote
Account Authsmtp

MaildirStore authsmtp-local
Subfolders Verbatim
# The trailing "/" is important
Path ~/.localsyncmail/authsmtp/
Inbox ~/.localsyncmail/authsmtp/Inbox

Channel authsmtp
Master :authsmtp-remote:
Slave :authsmtp-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 * "!Drafts"
Patterns *
# Automatically create missing mailboxes, both locally and on the server
Create Both
# Save the synchronization state files in the relevant directory
SyncState *

encrypt your mail pass

Create a temporary file .mbsyncpass and store your plain text password in there.

Next :

gpg --output .mbsyncpass.gpg --symmetric .mbsyncpass

Move mysyncpass.gpg in ~/.emacs.d and remove the .mbsyncpass file.

add mail source emmission

mu init –maildir=/local/mypathlocalsyncmail/account –my-address=email@mail.com –my-address=mail2@mail2.com

mbsync certificat trouble

you can use this script bellow : get_certs.sh

#!/bin/sh

SERVER=${1:-my.server.com}
PORT=${2:-993}
CERT_FOLDER=${3:-~/.cert}

openssl s_client -connect ${SERVER}:${PORT} -showcerts 2>&1 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'| sed -ne '1,/-END CERTIFICATE-/p' > ${CERT_FOLDER}/${SERVER}.pem

use it this way :

$ get_certs.sh mail.authsmtp.com

then move it to ~/.cert

run mbsync

$ mbsync -c ~/.emacs.d/.mbsyncrc authsmtp

index them for first time

$ nomad@wund:~$ mu index --maildir=./local/localsyncmail/authsmtp/