Skip to content

Postmark inbound test email can not be parsed #304

@Ecno92

Description

@Ecno92

It seems like the inbound test email from postmark can not be parsed by anymail

After pressing the check button in postmark:

Screenshot from 2023-04-03 15-34-29

  • Anymail version: 91.
  • ESP: Postmark
  • Your ANYMAIL settings (change secrets to "redacted"): According documentation, Work in progress during development..
  • Versions of Django, requests, python: python 3.10.6 with Django 4.1.7
  • Exact error message and/or stack trace
[03/Apr/2023 13:07:04] "POST /redacted/inbound/ HTTP/1.1" 500 104741
Internal Server Error: /redacted/inbound/
Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 55, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/anymail/webhooks/base.py", line 67, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/venv/lib/python3.10/site-packages/anymail/webhooks/base.py", line 81, in post
    events = self.parse_events(request)
  File "/opt/venv/lib/python3.10/site-packages/anymail/webhooks/postmark.py", line 26, in parse_events
    return [self.esp_to_anymail_event(esp_event)]
  File "/opt/venv/lib/python3.10/site-packages/anymail/webhooks/postmark.py", line 169, in esp_to_anymail_event
    attachments = [
  File "/opt/venv/lib/python3.10/site-packages/anymail/webhooks/postmark.py", line 172, in <listcomp>
    content=attachment["Content"],
KeyError: 'Content'

Some debugging

(Pdb) esp_event.get("Attachments", [])
[{'Name': 'test.txt', 'ContentType': 'text/plain', 'Data': 'VGhpcyBpcyBhdHRhY2htZW50IGNvbnRlbnRzLCBiYXNlLTY0IGVuY29kZWQu', 'ContentLength': 45}]

I checked the developer guide by postmark and it seems like anymail is doing the right thing.
The documentation also mentions Content, but in my case I'm seeing a Data key.

I'll follow up to figure out what's causing this issue. It might be an issue at Postmark, but given that the view crashes as a result of it I'll report it here first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions