Yaky's

PinePhone - ProtonMail

My setup for using ProtonMail on PinePhone.

Overview

ProtonMail works very well in Firefox on my desktop machine and on the iOS app. On the PinePhone, it is very slow (yet still usable) in the browser.
Another way to use ProtonMail is to run Proton Bridge to encrypt/decrypt the mailbox locally, and access the mail with an email client. However, the site says Proton Bridge is only available for subscribers. I have note tested this with a free account.

Email client

Install Geary email client if you don't have it:
sudo apk add geary

Build Proton Bridge

Build and install Proton Bridge (without GUI) from source:
Reddit post
sudo apk add make git go gcc libsecret-dev libc-dev
git clone https://github.com/ProtonMail/proton-bridge
cd proton-bridge
make build-nogui
If you are on Alpine 3.19 (postmarketOS 23.12), then you might need to build with additional flags (due to a musl issue with some functions):
CGO_CFLAGS="-D_LARGEFILE64_SOURCE" make build-nogui
Move the main executable to a directory under $PATH:
cp bridge ~/.local/bin/
Note: `bridge` is the main executable, and `proton-bridge` is a launcher, but that is less noticeable for CLI. The main difference is that `bridge` can run in non-interactive mode ("-n" switch), which is relevant later

Configure Proton Bridge

Configure Proton Bridge via CLI interface:
Proton bridge CLI guide
bridge --cli
Login: Use your ProtonMail username, not the email alias. Sync might take a while.
>>> login
Username:
Password:
Authenticating...
Account username was added successfully.
>>> A sync has begun for username
A sync has finished for username.
Get the IMAP/SMTP info:
>>> info
Configuration for username@proton.me
IMAP Settings
Address:   127.0.0.1
IMAP port: 1143
Username:  username@proton.me
Password:  a1b2c3d4e5f6g7h8i9j0k1
Security:  STARTTLS

SMTP Settings
Address:   127.0.0.1
SMTP port: 1025
Username:  username@proton.me
Password:  a1b2c3d4e5f6g7h8i9j0k1
Security:  STARTTLS
Remember it for the next step.

Connect to Proton Bridge from Geary

Since Proton Bridge hosts IMAP and SMTP servers, you need to run both Proton Bridge and Geary at the same time.
Once you set up Proton Bridge with your account, you can run it in non-interactive mode:
bridge -n
While Proton Bridge is running, run Geary and add a new account. Enter username and password from IMAP/SMTP info from Proton Bridge. In my case, Geary automatically connected to localhost, which is correct.
Wait for Geary to sync the mail and you're set.

Automation

Since Proton Bridge claims it can take up to half of all RAM, I don't want to run it all of the time, nor make it into a service. All I want is to be able to easily run Proton Bridge and Geary at the same time, and then to shut down Proton Bridge when I close Geary.
This is the script to do so:
bridge -n & geary; kill $!
Quick explanation:

Icon

If you want a nice desktop icon, here is one from Proton Bridge's site:
A nice icon for Proton Bridge
Create a directory for icons and save the icon to it: (change `/home/user` to the appropriate user)
mkdir /home/user/.local/share/icons
wget https://yaky.dev/2023-12-15-pinephone-protonmail/proton-bridge.png -P /home/user/.local/share/icons/

Desktop Entry

Make a desktop entry: (change `/home/user` to the appropriate user)
$EDITOR /home/user/.local/share/applications/protonmail.desktop
[Desktop Entry]
Name=ProtonMail
GenericName=Email
Comment=Send and receive email
Keywords=Email;E-mail;Mail;
Icon=/home/user/.local/share/icons/proton-bridge.png
Exec=/bin/sh -c "bridge -n & geary; kill $!"
Type=Application
Terminal=false
Categories=GNOME;GTK;Network;Email;

Now just launch the new icon and enjoy the 2-in-1 ProtonMail experience.