This works on my Manjaro setup as of 2024-03-07. I can’t guarantee it will work with anything else. I took part of these instructions from another blog post (thanks!), but they have been adapted specifically to work with Protonmail Bridge.
First install openssl
and isync
if not already installed
Then install mu
from AUR: https://aur.archlinux.org/packages/mu
Open Protonmail Bridge and copy your password into the file ~/.emacs.d/.mbsyncpass
; then encrypt it and delete the file with the unencrypted password:
$ cd ~/.emacs.d
$ gpg2 --output .mbsyncpass.gpg --symmetric .mbsyncpass
$ shred -u .mbsyncpass
Put the following into the file ~/.authinfo
, replacing “you@proton.me” with your Protonmail username and “really#!!1good__pass0” with your Protonmail password from the Bridge app. Make sure that it matches the details for your SMTP credentials.
machine 127.0.0.1 login you@proton.me port 1025 password really#!!1good__pass0
Then encrypt that file and delete the unencrypted version:
$ cd ~
$ gpg2 --output ~/.authinfo.gpg --symmetric ~/.authinfo
$ shred -u .authinfo
Check whether cert.pem
exists in the folder ~/.config/protonmail/bridge/
already. If not, export your certificate from the Bridge app, by going to Settings > Export TLS certificates, and save them in ~/.config/protonmail/bridge/
; you may need to create this folder if it doesn’t exist.
Make a config file for isync, ~/.emacs.d/.mbsyncrc
with the following contents. Replace “you@proton.me” with your Protonmail email address.
IMAPAccount protonmail
Host 127.0.0.1
User you@proton.me
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.emacs.d/.mbsyncpass.gpg"
Port 1143
SSLType STARTTLS
AuthMechs *
CertificateFile ~/.config/protonmail/bridge/cert.pem
IMAPStore protonmail-remote
Account protonmail
MaildirStore protonmail-local
Path ~/.protonmail/mbsyncmail/
Inbox ~/.protonmail/mbsyncmail/INBOX
SubFolders Verbatim
Channel protonmail
Far :protonmail-remote:
Near :protonmail-local:
Patterns *
Create Near
Sync All
Expunge None
SyncState *
Finally, configure Emacs to use mu4e. I put the following in my ~/.emacs
file. Some of it is personal preferences (like the bookmarks) but some of it you’ll need in order to get the thing to work at all (like the “changefilenames when moving” part). Make sure to replace “you@proton.me” with your Protonmail address.
;; This loads mu4e
(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e")
(require 'mu4e)
;; This tells mu4e what your email address is
(setq user-mail-address "you@proton.me")
;; SMTP settings:
(setq send-mail-function 'smtpmail-send-it) ; should not be modified
(setq smtpmail-smtp-server "127.0.0.1") ; host running SMTP server
(setq smtpmail-smtp-service 1025) ; SMTP service port number
(setq smtpmail-stream-type 'starttls) ; type of SMTP connections to use
;; Mail folders:
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-trash-folder "/Trash")
;; The command used to get your emails (adapt this line, see section 2.3):
(setq mu4e-get-mail-command "mbsync --config ~/.emacs.d/.mbsyncrc protonmail")
;; Further customization:
(setq mu4e-html2text-command "w3m -T text/html" ; how to handle html-formatted emails
mu4e-update-interval 300 ; seconds between each mail retrieval
mu4e-headers-auto-update t ; avoid to type `g' to update
mu4e-view-show-images t ; show images in the view buffer
mu4e-compose-signature-auto-include nil ; I don't want a message signature
mu4e-use-fancy-chars t) ; allow fancy icons for mail threads
;; Do not reply to yourself:
(setq mu4e-compose-reply-ignore-address '("no-?reply" "you@proton.me"))
;; maildirs
(setq mu4e-maildir-shortcuts
'( (:maildir "/Inbox" :key ?i)
(:maildir "/All mail" :key ?a)
(:maildir "/Folders/Work" :key ?w)))
;; signature
(setq message-signature "bgc")
(setq mu4e-bookmarks
'((:name "Unread messages"
:query "flag:unread and maildir:/Inbox"
:key ?u)
(:name "Today's messages"
:query "date:today..now"
:key ?t)
(:name "Last 7 days"
:query "date:7d..now"
:key ?7)
(:name "Messages with Word docs"
:query "mime:application/msword OR mime:application/vnd.openxmlformats-officedocument.wordprocessingml.document"
:key ?w)
(:name "Messages with PDF"
:query "mime:application/pdf"
:key ?p)
(:name "Messages with calendar event"
:query "mime:text/calendar"
:key ?e)
))
;; This fixes a frustrating bug, thanks @gnomon@mastodon.social
(setq mu4e-change-filenames-when-moving t)
Last thing to do is create the folders where mu
will store your messages and then start it indexing!
$ cd ~
$ mkdir .protonmail
$ mkdir .protonmail/mbsyncmail
$ mu init --maildir=~/.protonmail/mbsyncmail/ --myaddress=you@proton.me
$ mbsync --config ~/.emacs.d/.mbsyncrc protonmail
$ mu index
This will fetch all your email and save it in that folder. It might take a while. When this all finishes, you can open up Emacs and M-x mu4e
will open up mu4e for you!