Try ERPNext Buy Support Partners Foundation

Pull_from_email_account + email_account.receive errors

Hello!
I have a weird email error, could you help me out?

Should I open a github issue?
I have this email problem:

pull_from_email_account

Error

{'e': InternalError(1366, "Incorrect string value: '\\xE9b \\xDCl\\xF5...' for column `_1bd3e0294da19198`.`tabUnhandled Email`.`raw` at row 1"), 'method_name': 'pull_from_email_account', 'log': <function log at 0x7f1ba1523e18>, 'retry': 0, 'is_async': True, 'user': 'Administrator', 'kwargs': {'email_account': 'Replies'}, 'job_name': 'pull_from_email_account|Replies', 'event': 'all', 'method': <function pull_from_email_account at 0x7f1ba14297b8>, 'site': 'site1.local'}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 280, 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 392, in insert_communication
    communication.insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 229, in insert
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 888, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 787, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1058, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1041, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 781, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 65, in validate
    self.set_timeline_links()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 261, in set_timeline_links
    contacts = get_contacts([self.sender, self.recipients, self.cc, self.bcc])
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 344, in get_contacts
    for email in email_string.split(","):
AttributeError: 'Header' object has no attribute 'split'

During handling of the above exception, another exception occurred:

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 724, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 289, in receive
    self.handle_bad_emails(email_server, uid, msg, frappe.get_traceback())
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 323, in handle_bad_emails
    unhandled_email.insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 244, in insert
    self.db_insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 324, in db_insert
    ), list(d.values()))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 156, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1366, "Incorrect string value: '\\xE9b \\xDCl\\xF5...' for column `_1bd3e0294da19198`.`tabUnhandled Email`.`raw` at row 1")
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 280, 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 392, in insert_communication
    communication.insert(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 229, in insert
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 888, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 787, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1058, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1041, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 781, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 65, in validate
    self.set_timeline_links()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 261, in set_timeline_links
    contacts = get_contacts([self.sender, self.recipients, self.cc, self.bcc])
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 344, in get_contacts
    for email in email_string.split(","):
AttributeError: 'Header' object has no attribute 'split'

++++

pull_from_email_account

Hiba	

{'method_name': 'pull_from_email_account', 'log': <function log at 0x7f1ba1523e18>, 'retry': 0, 'is_async': True, 'user': 'Administrator', 'kwargs': {'email_account': 'Replies'}, 'job_name': 'pull_from_email_account|Replies', 'event': 'all', 'method': <function pull_from_email_account at 0x7f1ba14297b8>, 'site': 'site1.local'}
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 724, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 303, 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 280, 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 337, 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 489, in get_payload\n    charset = self.get_charset(part)\n  File \"/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py\", line 484, in get_charset\n    charset = chardet.detect(cstr(part))['encoding']\n  File \"/home/frappe/frappe-bench/env/lib/python3.6/site-packages/chardet/__init__.py\", line 34, in detect\n    '{0}'.format(type(byte_str)))\nTypeError: Expected object of type bytes or bytearray, got: <class 'str'>\n"
]
email_account.receive

Hiba	

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 280, 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 337, 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 489, in get_payload
    charset = self.get_charset(part)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 484, in get_charset
    charset = chardet.detect(cstr(part))['encoding']
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/chardet/__init__.py", line 34, in detect
    '{0}'.format(type(byte_str)))
TypeError: Expected object of type bytes or bytearray, got: <class 'str'>

Installed Apps

ERPNext: v12.3.1 (version-12)

Frappe Framework: v12.1.0 (version-12)

No problem it was charset again in mysql.cnf.