coddingtonbear / django-mailbox

Import mail from POP3, IMAP, local email mailboxes or directly from Postfix or Exim4 into your Django application automatically.
MIT License
353 stars 164 forks source link

Urgent: Error importing email #252

Open ptav opened 2 years ago

ptav commented 2 years ago

Hi, I started receiving a ValueError a few weeks ago after upgrading django-mailbox to 4.8.2 (django is 2.2.27). the DB is postgres which prevents string from been created from a NUL character. a empty string should be passed in this case.

ValueError: A string literal cannot contain NUL (0x00) characters.

Here is the full trace and I can also provide examples of the messages that are causing this error. It is a recurring problem that is causing considerable issues to our webapp so would appreciate if this could be looked at urgently - many thanks!

Traceback (most recent call last): File "manage.py", line 16, in execute_from_command_line(sys.argv) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, cmd_options) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, *options) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django_mailbox/management/commands/getmail.py", line 25, in handle for message in messages: File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django_mailbox/models.py", line 424, in get_new_mail msg = self.process_incoming_message(message) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django_mailbox/models.py", line 240, in process_incoming_message msg = self._process_message(message) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django_mailbox/models.py", line 378, in _process_message msg.save() File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/base.py", line 744, in save force_update=force_update, update_fields=update_fields) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/base.py", line 782, in save_base force_update, using, update_fields, File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/base.py", line 873, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/base.py", line 911, in _do_insert using=using, raw=raw) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(args, kwargs) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/query.py", line 1186, in _insert return query.get_compiler(using=using).execute_sql(return_id) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1377, in execute_sql cursor.execute(sql, params) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/home/crr/.virtualenvs/forum/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) ValueError: A string literal cannot contain NUL (0x00) characters.

Pietro395 commented 8 months ago

Can you provide an email example so we can investigate this issue?

ptav commented 2 months ago

Hi Pietro, will come back when I've come across the error again. Have been able to fix it by removing the offending email from the import stack.

Coincidentally I am now getting a similar situation with a different error message: LookupError: unknown encoding: iso-8859-8-i.

Both errors may be related as both happen only with meeting invite emails sent from countries with non-English native languages. May also be that it is the same error but the error message has been made more relevant recently.

Will come back when I've come across the error again, thank you!

ptav commented 2 months ago

Have now saved one of the emails that causes the error. As it contains personal email details would prefer to send it privately only - let me know how best to do that or, alternatively, what information you need

Pietro395 commented 2 months ago

Have now saved one of the emails that causes the error. As it contains personal email details would prefer to send it privately only - let me know how best to do that or, alternatively, what information you need

Hi, can you remove personal information from the exported email? You can open it with a file editor