GithubHelp home page GithubHelp logo

arkoprovo1996 / protonmail-cli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dimkouv/protonmail-cli

0.0 1.0 0.0 97 KB

Command line utility for https://protonmail.com -- unofficial

License: MIT License

Python 100.00%

protonmail-cli's Introduction

ProtonMail CLI

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

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 "[email protected]" \
    -t "[email protected]" \
    -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 = [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.

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("[email protected]", "mypassword")

# send mails
client.send_mail(
    ["[email protected]", "[email protected]"],
    "subject",
    "my mail message"
)

# send mails as html
client.send_mail(
    ["[email protected]", "[email protected]"],
    "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

protonmail-cli's People

Contributors

arkoprovo1996 avatar dimkouv avatar harsh543 avatar janikgar avatar jondolan avatar wolfmah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.