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

"get_new_mail" fails with "KeyError: 'content-transfer-encoding'" if header is missing #136

Closed
sumpfralle opened this issue May 9, 2017 · 0 comments

Comments

@sumpfralle
Copy link
Contributor

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django_mailbox/management/commands/getmail.py", line 24, in handle
    messages = mailbox.get_new_mail()
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django_mailbox/models.py", line 373, in get_new_mail
    msg = self.process_incoming_message(message)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django_mailbox/models.py", line 216, in process_incoming_message
    msg = self._process_message(message)
  File "/srv/virtualenvs/stadtgestalten/lib/python3.4/site-packages/django_mailbox/models.py", line 355, in _process_message
    msg.set_body(message.as_string())
  File "/usr/lib/python3.4/email/message.py", line 159, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib/python3.4/email/generator.py", line 112, in flatten
    self._write(msg)
  File "/usr/lib/python3.4/email/generator.py", line 186, in _write
    msg.replace_header('content-transfer-encoding', munge_cte[0])
  File "/usr/lib/python3.4/email/message.py", line 559, in replace_header
    raise KeyError(_name)
KeyError: 'content-transfer-encoding'

The root cause seems to be python's issue 27321.

@ad-m ad-m closed this as completed in #137 May 10, 2017
ad-m pushed a commit to watchdogpolska/django-mailbox that referenced this issue Jul 9, 2017
Closes: coddingtonbear#136

Python's email module raises a KeyError if the header
'content-transfer-encoding' is missing:
  https://bugs.python.org/issue27321
ses4j added a commit to mathandpencil/django-mailbox that referenced this issue Feb 26, 2019
ses4j added a commit to mathandpencil/django-mailbox that referenced this issue Feb 26, 2019
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

1 participant