Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Connecting emacs and Protonmail Bridge

This guide will cover the basics on how to integrate emacs with the bridge using

  • mu4e
  • mbsync
  • smtpmail

I am going to assume that you already have installed the mentioned software, I am using Fedora 27 but it should work on any GNU/Linux distribution.

Create a configuration file ~/.mbsyncrc for mbsync

IMAPAccount protonmail
Host 127.0.0.1
Port 1143
User USERNAME_HERE@protonmail.com
Pass PASSWORD_PROVIDED_BY_BRIDGE
#Alternatively you can enter a command to retrieve your password
#PassCmd "gpg2 -q -d ~/.authinfo.gpg | awk 'FNR == 1 {print $8}'"

SSLType NONE

IMAPStore remote
Account protonmail

#You can change .mail to something else
MaildirStore local
Path ~/.mail/
Inbox ~/.mail/INBOX/

Channel inbox
Master :remote:
Slave :local:
Patterns * !"Drafts" !"All Mail"
Create Slave
#Expunge Both
SyncState *

Group protonmail
Channel inbox

Now to get/sync you mail, run on a terminal $ mbsync protonmail.

Next we need to create a file to log our credentials for sending mail with smtpmail. Create a file ~/.authinfo with the following contents

machine 127.0.0.1 login USERNAME_HERE@protonmail.com port 1143 password PASSWORD_PROVIDED_BY_BRIDGE
machine 127.0.0.1 login USERNAME_HERE@protonmail.com port 1025 password PASSWORD_PROVIDED_BY_BRIDGE

OPTIONAL: You should encrypt it one option is to use epa in emacs M-x epa-encrypt-file. Another is to set a symmetric encryption that will require some password $ gpg2 --symetric .authinfo.

This is a minimal configuration that you should include in your init.el configuration file.

(require 'mu4e)

(setq mu4e-maildir "~/.mail"
	mu4e-attachment-dir "~/downloads"
	mu4e-sent-folder "/Sent"
	mu4e-drafts-folder "/Drafts"
	mu4e-trash-folder "/Trash"
	mu4e-refile-folder "/Archive")

(setq user-mail-address "USERNAME_HERE@protonmail.com"
	user-full-name  "YOUR_NAME")

;; Get mail
(setq mu4e-get-mail-command "mbsync protonmail"
	mu4e-change-filenames-when-moving t   ; needed for mbsync
	mu4e-update-interval 120)             ; update every 2 minutes

;; Send mail
(setq message-send-mail-function 'smtpmail-send-it
	smtpmail-auth-credentials "~/.authinfo.gpg" ;; Here I assume you encrypted the credentials
	smtpmail-smtp-server "127.0.0.1"
	smtpmail-smtp-service 1025)

Now just launch M-x mu4e to read your mail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.