Giter VIP home page Giter VIP logo

protonmail-cli's People

Contributors

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protonmail-cli's Issues

client.parse_mails() returns None

The parse_mails function always returns None for me, leading to the script crashing on calls for e.g. client.has_new_mails()

Code:

import protonmail
client = protonmail.core.ProtonmailClient()
client.login("[email protected]", "password")
client.parse_mails()

Commenting out the following lines in core.py restored the script to working order:

    def parse_mails(self):
        """
        Reads and returns a list of Mails inside the current web driver's page
        :return: a list of Mail objects
        """
        # if not utilities.wait_for_elem(self.web_driver, variables.element_list_inbox['email_list_wrapper_id'], "id"):
        #     # for some reason the wrapper wasn't loaded
        #     return None

Sometimes the login works and sometimes it doesn't

[root@localhost protonmail-cli]# python3 example.py
[INFO] 2019-06-19 19:18:51: Initiating ProtonMail client
xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
[INFO] 2019-06-19 19:18:55: Logging in...
[INFO] 2019-06-19 19:19:35: Logged in successfully
Traceback (most recent call last):
File "example.py", line 21, in
as_html=True
File "/root/protonmail-cli/protonmail/core.py", line 404, in send_mail
""" % (message.replace('"', '\"')))
File "/usr/python3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/usr/python3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/python3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: SyntaxError: "" string literal contains an unescaped line break

##################
This was successful login, but I made an error when I sent the HTML email, and it was ok when I sent the text,

TypeError: 'NoneType' object is not iterable

When I start the login is running but cannot list the emails or check them

[INFO] 2021-11-20 13:47:23: Initiating ProtonMail client
[INFO] 2021-11-20 13:47:26: Logging in...
[INFO] 2021-11-20 13:47:34: Logged in successfully
[INFO] 2021-11-20 13:47:34: Opening https://mail.protonmail.com/inbox
Traceback (most recent call last):
  File "protonmail-cli.py", line 159, in <module>
    args.func(args)
  File "protonmail-cli.py", line 13, in subcommand_list
    for mail in client.get_mails(args.type):
TypeError: 'NoneType' object is not iterable

Display message body and content

Hi! first of all I want to thank you for putting such a great effort into this amazing solution for command line users. Unencrypted email is unnaceptable nowadays so this really makes a difference for sysadmins and people with low end machines that can't afford a fancy GUI running on top.

That said, I wanted to ask you if there is a way to display the message body and content, because the inbox option only seems to show subjets. I'll really apreciatte any help.

Thanks for your time and please excuse my broken english, I'm not american. Goodbye!

ImportError: No module named configparser

I followed the instruction, but it failed to run. Ubuntu 20.04 LTS.

test@ubuntu:~$ pip3 install -r /opt/protonmail-cli/requirements.pip
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.9.1-py3-none-any.whl (115 kB)
     |████████████████████████████████| 115 kB 892 kB/s 
Collecting selenium
  Downloading selenium-3.141.0-py2.py3-none-any.whl (904 kB)
     |████████████████████████████████| 904 kB 2.8 MB/s 
Collecting pyvirtualdisplay
  Downloading PyVirtualDisplay-1.3.2-py2.py3-none-any.whl (14 kB)
Collecting soupsieve>1.2
  Downloading soupsieve-2.0.1-py3-none-any.whl (32 kB)
Requirement already satisfied: urllib3 in /usr/lib/python3/dist-packages (from selenium->-r /opt/protonmail-cli/requirements.pip (line 2)) (1.25.8)
Collecting EasyProcess
  Downloading EasyProcess-0.3-py2.py3-none-any.whl (7.9 kB)
Installing collected packages: soupsieve, beautifulsoup4, selenium, EasyProcess, pyvirtualdisplay
Successfully installed EasyProcess-0.3 beautifulsoup4-4.9.1 pyvirtualdisplay-1.3.2 selenium-3.141.0 soupsieve-2.0.1
test@ubuntu:~$ protonmail-cli --help
Traceback (most recent call last):
  File "/usr/bin/protonmail-cli", line 3, in <module>
    import configparser
ImportError: No module named configparser
test@ubuntu:~$ 

ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-l46eq931/

[root@localhost ~]# pip3 install git+https://github.com/dimkouv/protonmail-cli
Collecting git+https://github.com/dimkouv/protonmail-cli
Cloning https://github.com/dimkouv/protonmail-cli to /tmp/pip-req-build-l46eq931
Running command git clone -q https://github.com/dimkouv/protonmail-cli /tmp/pip-req-build-l46eq931
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-req-build-l46eq931/setup.py", line 3, in
from protonmail import metadata
File "/tmp/pip-req-build-l46eq931/protonmail/init.py", line 1, in
from . import core, interactive, settings, utilities, variables, mail, metadata
File "/tmp/pip-req-build-l46eq931/protonmail/core.py", line 7, in
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-l46eq931/

configparser not found

File "/bin/protonmail-cli", line 3, in import configparser ImportError: No module named configparser

what do i need to install?

Sending attachment returns ElementNotInteractableException

hey,

just wanted to let you know that I get the following error when I try to send a mail with attachment

b


ElementNotInteractableException Traceback (most recent call last)
in ()
----> 1 client.send_mail([email], 'Missing data', message, attachments=['/media/sf_vm_share/mcrds/reports/test.txt'])

~/anaconda3/lib/python3.7/site-packages/protonmail/core.py in send_mail(self, to, subject, message, as_html, attachments)
275 variables.element_send_mail['to_field_css'])
276 for address in to:
--> 277 el.send_keys(address + ";")
278 time.sleep(0.2)
279

~/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py in send_keys(self, *value)
477 self._execute(Command.SEND_KEYS_TO_ELEMENT,
478 {'text': "".join(keys_to_typing(value)),
--> 479 'value': keys_to_typing(value)})
480
481 # RenderedWebElement Items

~/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webelement.py in _execute(self, command, params)
631 params = {}
632 params['id'] = self._id
--> 633 return self._parent.execute(command, params)
634
635 def find_element(self, by=By.ID, value=None):

~/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))

~/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):

ElementNotInteractableException: Message: Element is not reachable by keyboard

selenium error

Hello I am testing the library and when I run core_test.py I got:

======================================================================
ERROR: test_3_has_new_mail (main.CoreTest)

Traceback (most recent call last):
File "protonmail-cli/tests/core_test.py", line 56, in test_3_has_new_mail
self.client.has_new_mail()
File "/home/andrea/.local/lib/python3.6/site-packages/protonmail/core.py", line 282, in has_new_mail
for m in mails:
TypeError: 'NoneType' object is not iterable

======================================================================
ERROR: test_5_send_mail_html (main.CoreTest)

Traceback (most recent call last):
File "protonmail-cli/tests/core_test.py", line 77, in test_5_send_mail_html
"[Success] This message was automatically send from

protonmail-cli

tests."
File "/home/andrea/.local/lib/python3.6/site-packages/protonmail/core.py", line 420, in send_mail
el.click()
File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: Element is not clickable at point (1154,575) because another element
obscures it

======================================================================
FAIL: test_2_get_mails (main.CoreTest)

Traceback (most recent call last):
File "protonmail-cli/tests/core_test.py", line 42, in test_2_get_mails
"[%s] unable to load conversation wrapper" % page)
AssertionError: [inbox] unable to load conversation wrapper

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "protonmail-cli/tests/core_test.py", line 52, in test_2_get_mails
(page, str(e)))
AssertionError: [inbox] unable to read any mail error: [inbox] unable to load conversation wrapper


Ran 7 tests in 80.012s

FAILED (failures=1, errors=2)

Element input_id="username" is not reachable by keyboard

Not able to log into the protonmail CLI.

ProtonMail email or username: ******.net
ProtonMail password:
[INFO] 2022-04-15 17:51:43: Initiating ProtonMail client
[INFO] 2022-04-15 17:51:45: Logging in...
[INFO] 2022-04-15 17:51:50: Login failed!
Traceback (most recent call last):
  File "/opt/protonmail-cli/protonmail/core.py", line 69, in login
    username_input.send_keys(username)
  File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 540, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
  File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 710, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: Element <input id="username" class="w100 inputform-field"> is not reachable by keyboard
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5
ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.jsm:293:5
webdriverSendKeysToElement@chrome://remote/content/marionette/interaction.js:624:13
interaction.sendKeysToElement@chrome://remote/content/marionette/interaction.js:600:11
sendKeysToElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:497:24
receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:151:31

checked username/password and they are both able to log me into the website.

System specs;

5.15.28-1-MANJARO
geckodriver 0.30.0
firefox 99.0.1

Replace settings.py with a text-based file

Currently protonmail/settings.py holds user settings along with credentials.

This file could be replaced by a text-based file (json, csv, conf, ...) in order to store it on a safer location.

[Suggestion]
Add a default name for that file on protonmail/variables.py and store it by default under
protonmail-cli workdir (currently settings.py > work_directory, this should also be in variables.py).

If user doesn't specify the file from command line then open settings from the default file.

Crash on client.has_new_mail()

My account has 4 messages, all unread.

Code:

#!/usr/bin/python3
import protonmail

client = protonmail.core.ProtonmailClient()
client.login("", "")
mails = client.get_mails("inbox")
spam = client.get_mails("spam")
has_new_mail = client.has_new_mail()
client.destroy()

Output:

[INFO] 2019-06-20 06:01:27: Initiating ProtonMail client
[INFO] 2019-06-20 06:01:29: Logging in...
[INFO] 2019-06-20 06:01:39: Logged in successfully
[INFO] 2019-06-20 06:02:00: Opening https://mail.protonmail.com/spam
[INFO] 2019-06-20 06:02:23: Opening https://mail.protonmail.com/inbox
Traceback (most recent call last):
File "/home/user/.local/share/scripts/proton/pyScript.py", line 8, in
has_new_mail = client.has_new_mail()
File "/usr/lib/python3.7/site-packages/protonmail/core.py", line 282, in has_new_mail
for m in mails:
TypeError: 'NoneType' object is not iterable

Error: AttributeError: 'NoneType' object has no attribute 'current_url'

When ever I log into the system and type Inbox it throws this error:

Traceback (most recent call last): File "protonmail-cli.py", line 163, in <module> session.start() File "/opt/protonmail-cli/protonmail/interactive.py", line 160, in start options[choice]["function"]() # call the anonymous function that is attached on menu choice File "/opt/protonmail-cli/protonmail/interactive.py", line 135, in <lambda> "function": lambda: self.show(opt) File "/opt/protonmail-cli/protonmail/interactive.py", line 103, in show for mail in self.client.get_mails(page): File "/opt/protonmail-cli/protonmail/core.py", line 157, in get_mails if self.web_driver.current_url != url: AttributeError: 'NoneType' object has no attribute 'current_url'

Emails will only create drafts

So when I send emails from a file it will pop up in my Drafts folder and won't send to the recipient.

`

import protonmail

client = protonmail.core.ProtonmailClient()
client.login("********@protonmail.com", "*******")

client.send_mail(
["********@protonmail.com"],
"subject",
"my mail message"
)

`

Selenium error

Hello I am testing the library and when I run core_test.py I got:

======================================================================
ERROR: test_3_has_new_mail (__main__.CoreTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "protonmail-cli/tests/core_test.py", line 56, in test_3_has_new_mail
    self.client.has_new_mail()
  File "/home/andrea/.local/lib/python3.6/site-packages/protonmail/core.py", line 282, in has_new_mail
    for m in mails:
TypeError: 'NoneType' object is not iterable

======================================================================
ERROR: test_5_send_mail_html (__main__.CoreTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "protonmail-cli/tests/core_test.py", line 77, in test_5_send_mail_html
    "[Success] This message was automatically send from <h1>protonmail-cli</h1> tests."
  File "/home/andrea/.local/lib/python3.6/site-packages/protonmail/core.py", line 420, in send_mail
    el.click()
  File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/andrea/.local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: Element <button class="pm_button primary mobileFull composer-btn-send btnSendMessage-btn-action"> is not clickable at point (1154,575) because another element <div class="pull-right"> obscures it


======================================================================
FAIL: test_2_get_mails (__main__.CoreTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "protonmail-cli/tests/core_test.py", line 42, in test_2_get_mails
    "[%s] unable to load conversation wrapper" % page)
AssertionError: [inbox] unable to load conversation wrapper

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "protonmail-cli/tests/core_test.py", line 52, in test_2_get_mails
    (page, str(e)))
AssertionError: [inbox] unable to read any mail error: [inbox] unable to load conversation wrapper

----------------------------------------------------------------------
Ran 7 tests in 80.012s

FAILED (failures=1, errors=2)

AttributeError: NoneType object has no attribute 'current_url'

Installed the CLI a few mintues ago and tried running the interactive session. I could login but I couldn't check my inbox, and this error kept showing up.

Traceback (most recent call last):
  File "/usr/bin/protonmail-cli", line 163, in <module>
    session.start()
  File "/opt/protonmail-cli/protonmail/interactive.py", line 160, in start
    options[choice]["function"]()  # call the anonymous function that is attached on menu choice
  File "/opt/protonmail-cli/protonmail/interactive.py", line 135, in <lambda>
    "function": lambda: self.show(opt)
  File "/opt/protonmail-cli/protonmail/interactive.py", line 103, in show
    for mail in self.client.get_mails(page):
  File "/opt/protonmail-cli/protonmail/core.py", line 157, in get_mails
    if self.web_driver.current_url != url:
AttributeError: 'NoneType' object has no attribute 'current_url'```

Two-factor authentication

I use two-factor authentication. It should be a pretty easy add, and I'm working on a way to add it. If I get it working, is it okay if make a PR?

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.