question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V12 email pull error : AttributeError: 'Message' object has no attribute 'encode'

See original GitHub issue

pull_from_email_account

Error	

{'job_name': 'pull_from_email_account|Sales', 'method': <function pull_from_email_account at 0x7f76f7d2a8c8>, 'kwargs': {'email_account': 'Sales'}, 'log': <function log at 0x7f76f7d782f0>, 'event': 'all', 'method_name': 'pull_from_email_account', 'retry': 0, 'site': 'site1.local', 'user': 'Administrator', 'is_async': True}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 99, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 723, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 302, in receive
    raise Exception(frappe.as_json(exceptions))
Exception: [
 "Traceback (most recent call last):\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 279, in receive\n    communication = self.insert_communication(msg, args=args)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 336, in insert_communication\n    email = Email(raw)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 372, in __init__\n    self.parse()\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 393, in parse\n    self.process_part(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 445, in process_part\n    self.text_content += self.get_payload(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 492, in get_payload\n    charset = self.get_charset(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 487, in get_charset\n    charset = chardet.detect(part.encode())['encoding']\nAttributeError: 'Message' object has no attribute 'encode'\n"
]

email_account.receive

Error	

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 279, in receive
    communication = self.insert_communication(msg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 336, in insert_communication
    email = Email(raw)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 372, in __init__
    self.parse()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 393, in parse
    self.process_part(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 445, in process_part
    self.text_content += self.get_payload(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 492, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 487, in get_charset
    charset = chardet.detect(part.encode())['encoding']
AttributeError: 'Message' object has no attribute 'encod
```e'

@krnkris  reported this
It is introduced due to fix 
[8061](https://github.com/frappe/frappe/pull/8061)
[8060(]https://github.com/frappe/frappe/pull/8060  )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ashish-greycubecommented, Aug 22, 2019

@govindsmenokee it is merged in v-12-hotfix https://github.com/frappe/frappe/pull/8204 It should be available in Tuesday release i.e. 27th Aug

1reaction
ashish-greycubecommented, Aug 9, 2019

@krnkris thanks for reporting this. it is fixed via https://github.com/frappe/frappe/pull/8148 - for v12 https://github.com/frappe/frappe/pull/8147 - for v11

Read more comments on GitHub >

github_iconTop Results From Across the Web

'bytes' object has no attribute 'encode' in EmailMessage
The problem is that you're sending a PDF file object as the message body: pdf = weasyprint.HTML(string=html, base_url='').write_pdf( ...
Read more >
Pull_from_email_account & email_account.receive errors - Bug
I have a weird issue with reoccurring errors. Seems to have to do with my ... AttributeError: 'Message' object has no attribute 'encode'...
Read more >
AttributeError when trying to send an utf-8 encoded email with ...
I get "AttributeError: 'bytes' object has no attribute 'encode'" when trying to send a utf-8 encoded email with text attachments (see stack trace...
Read more >
Sending mails with attachment results in 'bytes' object has no ...
packages/django/core/mail/message.py", line 292, in send ... AttributeError: 'bytes' object has no attribute 'encode' }}}. As it turns out:.
Read more >
Release Notes — Airflow Documentation
Meaningful error message in resolve_template_files (#23027) ... Fix AttributeError : datetime.timezone object has no attribute name (#16599).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found