Menu

Tree [64b72f] master /
 History

HTTPS access


File Date Author Commit
 protonmail 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 tests 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 .gitignore 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 LICENSE 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 README.md 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 protonmail-cli.py 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 requirements.pip 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit
 setup.py 2019-11-22 Arkoprovo Ghosh Arkoprovo Ghosh [64b72f] Initial commit

Read Me

ProtonMail CLI

This version has been forked from https://github.com/dimkouv/protonmail-cli because of maintainance issues

protonmail-cli v0.0.3
Python 3
OS
Unofficial

Command line utility for https://protonmail.com

Installation

System dependencies (Probably everything's already installed)

apt install -y xvfb python3-pip firefox                 # on debian
dnf install xorg-x11-server-Xvfb python3-pip firefox    # on fedora
pacman -S xorg-server-xvfb python-pip firefox wget      # on arch

Geckodriver

# Find your release: https://github.com/mozilla/geckodriver/releases

# for linux x64
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
# for arm 7
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-arm7hf.tar.gz
# for linux x32
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux32.tar.gz

tar -xvf geckodriver-*.tar.gz -C /bin/
rm geckodriver-*.tar.gz

for Arch Linux based systems

pacman -S xorg-server-xvfb python-pip firefox wget xorg-xdpyinfo geckodriver

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

Usage

Use as a command line

# show full usage
protonmail-cli --help
# each sub-command has its own `--help` section.

# 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 "one@protonmail.com" \
    -t "two@pm.me" \
    -s "my subject" \
    -b "my mail message" \
    --html # (optional if you want to render body as html) \
    -a "/path/to/file.jpg" \ # (optional for adding attachments)
    -a "/path/to/other/file.pdf"

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.

If user credentials are not specified in settings.py or credentials file then cli prompts you to type them.

Example usage of separate credentials file

# /home/user/protonmailcli.ini

[credential]
username = mymail@protonmail.com
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.

Run in an interactive session

Simply run protonmail-cli without any parameters to open an interactive session.

[Anonymous] Choose an option from the menu
m           : Shows this menu
x           : Exit
l           : Login
> l
ProtonMail email or username: dimkouv
ProtonMail password:
Loading...
Welcome dimkouv

[dimkouv] Choose an option from the menu
m           : Shows this menu
x           : Exit
e           : Logout
inbox       : Show inbox mails
drafts      : Show drafts
sent        : Show sent mails
starred     : Show starred mails
archive     : Show archived mails
spam        : Show spam mails
trash       : Show trash mails
allmail     : Show all mails
>

Use as a package

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("mymail@protonmail.com", "mypassword")

# send mails
client.send_mail(
    ["one@protonmail.com", "two@pm.me"],
    "subject",
    "my mail message"
)

# send mails as html
client.send_mail(
    ["one@protonmail.com", "two@pm.me"],
    "subject",
    """
    <h1>hello friend</h1>
    <p>This message was sent from <strong>protonmail-cli</strong></p>
    """,
    as_html=True
)

# upload attachments
client.send_mail(
    ...,
    attachments=[
        '/path/to/file.jpg',
        '/path/to/other/file.pdf'
    ]
)

# 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()

Testing

cd protonmail-cli
virtualenv -p python3 venv
source venv/bin/activate
pip install .
python3 tests/core_test.py
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.