Command line utility for https://protonmail.com
System dependencies
apt install -y xvfb python3-pip firefox # on debian
dnf install xorg-x11-server-Xvfb python3-pip firefox # on fedora
Geckodriver
# Find your release: https://github.com/mozilla/geckodriver/releases
# for linux x64
wget https://github.com/mozilla/geckodriver/releases/download/v0.21.0/geckodriver-v0.21.0-linux64.tar.gz
tar -xvf geckodriver-*.tar.gz -C /bin/
rm geckodriver-*.tar.gz
Protonmail CLI
git clone https://github.com/dimkouv/protonmail-cli /opt/protonmail-cli
ln -s /opt/protonmail-cli/protonmail-cli.py /bin/protonmail-cli
pip3 install -r /opt/protonmail-cli/requirements.pip
protonmail-cli
works with sub-command, like the cli command git
.
To see all possible usage, each sub-command has its own --help
section.
# show full usage
protonmail-cli --help
# list inbox - print latest mails
protonmail-cli list -t inbox
protonmail-cli list -t spam
# check inbox for new mails
protonmail-cli check
# send mail
protonmail-cli send \
-t "[email protected]" \
-t "[email protected]" \
-s "my subject" \
-b "my mail message"
Global settings, including user credentials, can be specified on /opt/protonmail-cli/protonmail/settings.py
User credentials can also be set in their own file, overriding those found inside
settings.py
. The global argument --credential
allow you to set the file path of
this config file. This would allow better security by allowing each user of a multi-users
machine to keep their credentials inside their home folder.
Example usage of separate credentials file
# /home/user/protonmailcli.ini
[credential]
username = [email protected]
password = mysafepass
protonmail-cli --credential /home/user/protonmailcli.ini list
For even better security, chmod 600
this file, so only the user launching the
application can read it.
Core functions can be called directly from your code instead of using protonmail-cli
pip3 install git+https://github.com/dimkouv/protonmail-cli
Usage example
import protonmail
client = protonmail.core.ProtonmailClient()
client.login("[email protected]", "mypassword")
# send mails
client.send_mail(
["[email protected]", "[email protected]"],
"subject",
"my mail message"
)
# read mails
mails = client.get_mails("inbox")
spam = client.get_mails("spam")
# check for new mail
has_new_mail = client.has_new_mail()
client.destroy()
cd protonmail-cli
virtualenv -p python3 venv
source venv/bin/activate
pip install .
python3 tests/core_test.py