Skip to content

AttributeError: 'NoneType' object has no attribute 'items' when handling multipart messages with attachments #560

@hunhejj

Description

@hunhejj

When an SMTP client sends a multipart email with an attachment, i.e. multipart/mixed containing a binary attachment (e.g., PDF), aiosmtpd crashes.

This was observed through the smtp2mqtt add-on, which uses aiosmtpd, but the stack trace points clearly to aiosmtpd/smtp.py.

PHP version: 3.11.8

Traceback (most recent call last):
  File ".../aiosmtpd/smtp.py", line 756, in _handle_client
    await method(arg)
  File ".../aiosmtpd/smtp.py", line 1519, in smtp_DATA
    status = await self._call_handler_hook('DATA')
  File ".../aiosmtpd/smtp.py", line 473, in _call_handler_hook
    status = await hook(self, self.session, self.envelope, *args)
  File "/app/smtp2mqtt.py", line 96, in handle_DATA
    for header in msgBody.items():
AttributeError: 'NoneType' object has no attribute 'items'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions