Communication: Cannot receive two different communications from the same e-mail

So I discovered a strange issue, if there is the same e-mail sending two different e-mails with different subject, ERPNext Communications module doesn’t allow the second e-mail.

It provides an error that the name of the sender is duplicate.

Has anyone experienced this before ?

Julian

Anybody has any idea why this is happening ?

Julian

Do you create Contacts based on senders? Give it a try to uncheck that in the Email Account settings.

Originally yes. I tested without that setting and still having the same problem.

Duplicate entry

Traceback with variables (most recent call last):
  File "apps/frappe/frappe/utils/background_jobs.py", line 165, in execute_job
    retval = method(**kwargs)
      site = 'comm.komodoresort.com'
      method = <function pull_from_email_account at 0x7ff93be32cb0>
      event = 'all'
      job_name = 'pull_from_email_account|Komodo Resort'
      kwargs = {'email_account': 'Komodo Resort'}
      user = 'Administrator'
      is_async = True
      retry = 0
      retval = None
      method_name = 'pull_from_email_account'
      before_job_task = 'frappe.monitor.start'
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 813, in pull_from_email_account
    email_account.receive()
      email_account = <EmailAccount: Komodo Resort>
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 475, in receive
    raise Exception(frappe.as_json(exceptions))
      self = <EmailAccount: Komodo Resort>
      exceptions = ['Traceback (most recent call last):\n  File "apps/frappe/frappe/model/base_document.py", line 496, in db_insert\n    frappe.db.sql(\n  File "apps/frappe/frappe/database/database.py", line 219, in sql\n    self._cursor.execute(query, values)\n  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute\n    result = self._query(query)\n  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query\n    conn.query(q)\n  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query\n    self._affected_rows = self._read_query_result(unbuffered=unbuffered)\n  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result\n    result.read()\n  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read\n    first_packet = self.connection._read_packet()\n  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet\n    packet.raise_for_error()\n...
      inbound_mails = [<frappe.email.receive.InboundMail object at 0x7ff93b129db0>]
      mail = <frappe.email.receive.InboundMail object at 0x7ff93b129db0>
builtins.Exception: [
 "Traceback (most recent call last):\n  File \"apps/frappe/frappe/model/base_document.py\", line 496, in db_insert\n    frappe.db.sql(\n  File \"apps/frappe/frappe/database/database.py\", line 219, in sql\n    self._cursor.execute(query, values)\n  File \"env/lib/python3.10/site-packages/pymysql/cursors.py\", line 148, in execute\n    result = self._query(query)\n  File \"env/lib/python3.10/site-packages/pymysql/cursors.py\", line 310, in _query\n    conn.query(q)\n  File \"env/lib/python3.10/site-packages/pymysql/connections.py\", line 548, in query\n    self._affected_rows = self._read_query_result(unbuffered=unbuffered)\n  File \"env/lib/python3.10/site-packages/pymysql/connections.py\", line 775, in _read_query_result\n    result.read()\n  File \"env/lib/python3.10/site-packages/pymysql/connections.py\", line 1156, in read\n    first_packet = self.connection._read_packet()\n  File \"env/lib/python3.10/site-packages/pymysql/connections.py\", line 725, in _read_packet\n    packet.raise_for_error()\n  File \"env/lib/python3.10/site-packages/pymysql/protocol.py\", line 221, in raise_for_error\n    err.raise_mysql_exception(self._data)\n  File \"env/lib/python3.10/site-packages/pymysql/err.py\", line 143, in raise_mysql_exception\n    raise errorclass(errno, errval)\npymysql.err.IntegrityError: (1062, \"Duplicate entry 'Julian' for key 'PRIMARY'\")\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"apps/frappe/frappe/email/doctype/email_account/email_account.py\", line 453, in receive\n    communication = mail.process()\n  File \"apps/frappe/frappe/email/receive.py\", line 693, in process\n    return self._build_communication_doc()\n  File \"apps/frappe/frappe/email/receive.py\", line 724, in _build_communication_doc\n    communication.insert(ignore_permissions=True)\n  File \"apps/frappe/frappe/model/document.py\", line 270, in insert\n    self.db_insert(ignore_if_duplicate=ignore_if_duplicate)\n  File \"apps/frappe/frappe/model/base_document.py\", line 523, in db_insert\n    raise frappe.DuplicateEntryError(self.doctype, self.name, e)\nfrappe.exceptions.DuplicateEntryError: ('Communication', 'Julian', IntegrityError(1062, \"Duplicate entry 'Julian' for key 'PRIMARY'\"))\n"
]