Skip to content

Instantly share code, notes, and snippets.

@A6GibKm
Last active November 15, 2025 16:32
Show Gist options
  • Select an option

  • Save A6GibKm/238b754a4a90051f60906b9efa3e8000 to your computer and use it in GitHub Desktop.

Select an option

Save A6GibKm/238b754a4a90051f60906b9efa3e8000 to your computer and use it in GitHub Desktop.

Revisions

  1. A6GibKm revised this gist Apr 21, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mu4e.md
    Original file line number Diff line number Diff line change
    @@ -118,7 +118,7 @@ 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
    `$ gpg --symetric .authinfo`. Finally delete `.authinfo`.
    `$ gpg --symmetric .authinfo`. Finally delete `.authinfo`.


    Now to get/sync you mail, run on a terminal `$ mbsync protonmail`.
  2. A6GibKm revised this gist Jun 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mu4e.md
    Original file line number Diff line number Diff line change
    @@ -114,7 +114,7 @@ machine 127.0.0.1 port 1143 login USERNAME@protonmail.com password BRIDGE_PASSWO
    machine 127.0.0.1 port 1025 login USERNAME@protonmail.com password BRIDGE_PASSWORD
    ```

    You should encrypt it
    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
  3. A6GibKm revised this gist Jun 23, 2020. 1 changed file with 67 additions and 2 deletions.
    69 changes: 67 additions & 2 deletions mu4e.md
    Original file line number Diff line number Diff line change
    @@ -41,12 +41,77 @@ Channel inbox
    ```

    ## (Alternative to mbsync) Using offlineimap

    Alternatively install `offlineimap` with the following config at `~/.offlineimaprc`

    ```conf
    # ~/.offlineimaprc
    [general]
    accounts = protonmail
    pythonfile = ~/.config/offlineimap/keyring.py
    metadata = ~/.cache/offlineimap
    [Account protonmail]
    remoterepository = protonmail-remote
    localrepository = protonmail-local
    [Repository protonmail-local]
    type = Maildir
    localfolders = ~/.mail
    sync_deletes = no
    [Repository protonmail-remote]
    expunge = yes
    type = IMAP
    remotehost = 127.0.0.1
    remoteport= 1143
    remoteuser = USERNAME@protonmail.com
    remotepasseval = get_password("USERNAME@protonmail.com")
    # Alternatively, use
    # remotepass = <YOUR BRIDGE-SPECIFIC PASSWORD>
    nametrans = lambda foldername: re.sub ('^Folders.', '', foldername)
    folderfilter = lambda foldername: foldername not in ['All Mail']
    ssl = no # ssl is broken.
    starttls = yes
    ssl_version = tls1_2
    sslcacertfile = ~/.config/protonmail/bridge/cert.pem
    ```

    Where one possible script is

    ```python
    #!/usr/bin/env python3
    # ~/.config/offlineimap/keyring.py

    import re
    import os


    def get_password(login):
    machine = "127.0.0.1"
    port = "1143"
    s = "machine %s port %s login %s password ([^ ]*)\n" % (
    machine,
    port,
    login,
    )
    p = re.compile(s)
    authinfo = os.popen(
    "gpg -q --no-tty -d ~/.authinfo.gpg"
    ).read()
    return p.search(authinfo).group(1)
    ```

    **Note**: offlineimap depends on deprecated Python 2.7.

    ## Logging credentials

    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
    machine 127.0.0.1 port 1143 login USERNAME@protonmail.com password BRIDGE_PASSWORD
    machine 127.0.0.1 port 1025 login USERNAME@protonmail.com password BRIDGE_PASSWORD
    ```

    You should encrypt it
  4. A6GibKm revised this gist Aug 16, 2019. 1 changed file with 2 additions and 6 deletions.
    8 changes: 2 additions & 6 deletions mu4e.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,11 @@
    # Connecting emacs and Protonmail Bridge

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

    * [mu4e](http://www.djcbsoftware.nl/code/mu/mu4e.html)
    * mbsync
    * smtpmail
    * [protonmail-bridge](https://protonmail.com/bridge/)

    How to install them:

    * Fedora: `sudo dnf install isync maildir-utils`
    * Debian: `sudo apt install isync maildir-utils`

    # Configuring mbsync

  5. A6GibKm revised this gist Aug 16, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mu4e.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ How to install them:

    Create a configuration file `~/.mbsyncrc` for mbsync

    ``` conf
    ```conf
    IMAPAccount protonmail
    Host 127.0.0.1
    Port 1143
  6. A6GibKm revised this gist Aug 16, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mu4e.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ How to install them:

    Create a configuration file `~/.mbsyncrc` for mbsync

    ```
    ``` conf
    IMAPAccount protonmail
    Host 127.0.0.1
    Port 1143
  7. A6GibKm revised this gist Aug 16, 2019. 1 changed file with 10 additions and 4 deletions.
    14 changes: 10 additions & 4 deletions mu4e.md
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@ This guide will cover the basics on how to integrate emacs with the bridge using
    * mbsync
    * smtpmail

    How to install them:
    How to install them:

    * Fedora: `sudo dnf install isync maildir-utils`
    * Debian: `sudo apt install isync maildir-utils`

    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.
    # Configuring mbsync

    Create a configuration file `~/.mbsyncrc` for mbsync

    @@ -45,7 +45,7 @@ Channel inbox
    ```

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

    Next we need to create a file to log our credentials for sending mail with smtpmail. Create a file `~/.authinfo` with the following contents
    ```
    @@ -59,6 +59,11 @@ one option is to use `epa` in emacs
    Another is to set a symmetric encryption that will require some password
    `$ gpg --symetric .authinfo`. Finally delete `.authinfo`.


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

    # Configuring mu4e

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

    ```lisp
    @@ -85,5 +90,6 @@ smtpmail-smtp-service 1025)
    (add-to-list 'gnutls-trustfiles (expand-file-name "~/.config/protonmail/bridge/cert.pem"))
    ```
    To index your emails from the terminal run `mu index --maildir=~/.mail`

    Now just launch `M-x mu4e` to read your mail.
    Now just launch `M-x mu4e` from emacs to read your mail.
  8. A6GibKm revised this gist Aug 16, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions mu4e.md
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,10 @@ This guide will cover the basics on how to integrate emacs with the bridge using
    * mbsync
    * smtpmail

    - Fedora: `sudo dnf install isync maildir-utils`
    - Debian: `sudo apt install isync maildir-utils`
    How to install them:

    * Fedora: `sudo dnf install isync maildir-utils`
    * Debian: `sudo apt install isync maildir-utils`

    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.

  9. A6GibKm created this gist Aug 16, 2019.
    87 changes: 87 additions & 0 deletions mu4e.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    # Connecting emacs and Protonmail Bridge

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

    * [mu4e](http://www.djcbsoftware.nl/code/mu/mu4e.html)
    * mbsync
    * smtpmail

    - Fedora: `sudo dnf install isync maildir-utils`
    - Debian: `sudo apt install isync maildir-utils`

    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
    PassCmd "gpg -q --for-your-eyes-only --no-tty -d ~/.authinfo.gpg | awk 'FNR == 1 {print $8}'"
    SSLType STARTTLS
    SSLVersions TLSv1.2
    CertificateFile ~/.config/protonmail/bridge/cert.pem
    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 *
    Create Both
    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
    ```

    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
    `$ gpg --symetric .authinfo`. Finally delete `.authinfo`.

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

    ```lisp
    (require 'mu4e)
    (setq mu4e-maildir "~/.mail"
    mu4e-attachment-dir "~/Downloads")
    (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"
    smtpmail-smtp-server "127.0.0.1"
    smtpmail-stream-type 'starttls
    smtpmail-smtp-service 1025)
    (add-to-list 'gnutls-trustfiles (expand-file-name "~/.config/protonmail/bridge/cert.pem"))
    ```

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