Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems that the script don't run with python >= 3 #2

Open
Gitsaibot opened this issue Mar 3, 2022 · 1 comment
Open

It seems that the script don't run with python >= 3 #2

Gitsaibot opened this issue Mar 3, 2022 · 1 comment

Comments

@Gitsaibot
Copy link

Get errors like this:

    print "<"+str(mail['date'])+"> "+"["+str(mail['from'])+"] :"+str(mail['subject'])
          ^
*SyntaxError: invalid syntax*

First error solved with print(...)


Traceback (most recent call last):
  File "/home/tobias/ExtractMailAttachment.py", line 80, in <module>
    mail = email.message_from_string(email_body)
  File "/usr/lib/python3.9/email/__init__.py", line 38, in message_from_string
    return Parser(*args, **kws).parsestr(s)
  File "/usr/lib/python3.9/email/parser.py", line 67, in parsestr
    return self.parse(StringIO(text), headersonly=headersonly)
*TypeError: initial_value must be str or None, not bytes*

Here I need help...

@auino
Copy link
Owner

auino commented Mar 3, 2022

I confirm that it depends on the Python version used: the program works on python2. Hence, in your case, it is needed to port it to python3.
Particularly, python3 embeds the imaplib library (see https://www.devdungeon.com/content/read-and-send-email-python), hence, the best porting would make use of such library, instead of the email one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants