Skip to content

feat(inbound): MailgunInboundParser#28

Open
mpge wants to merge 1 commit intofeat/inbound-email-controllerfrom
feat/mailgun-inbound-parser
Open

feat(inbound): MailgunInboundParser#28
mpge wants to merge 1 commit intofeat/inbound-email-controllerfrom
feat/mailgun-inbound-parser

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented Apr 24, 2026

Summary

Adds Mailgun as the second supported inbound provider alongside Postmark (from #27). Mirrors the .NET counterpart (escalated-dotnet #25).

Mailgun POSTs multipart/form-data with snake-case field names (sender / recipient / body-plain / body-html / Message-Id / In-Reply-To / References / attachments). The Spring controller already ingests a Map<String, Object> from the webhook body, so this parser just reads from that map; the controller routes via ?adapter=mailgun.

Notes

  • Mailgun's from is typically "Name <email>" — we extract the display name portion and fall back to the sender field for the email. Surrounding quotes on the name are stripped.
  • Mailgun hosts attachment content behind a URL (large attachments). We carry the URL through in downloadUrl; a follow-up worker can fetch + persist out-of-band.
  • Malformed attachments JSON degrades gracefully (empty list).

Dependencies

Test plan

  • 7 JUnit tests cover core field extraction, threading headers, provider-hosted attachment parsing, malformed attachments JSON, sender→from fallback, bare-email (no display name) handling, and quote-stripping on display names
  • CI green (won't trigger against stacked base until rebased)

Adds Mailgun as the second supported inbound provider alongside
Postmark (from #27). Mailgun POSTs multipart/form-data with
snake-case field names — the Spring controller already ingests a
Map<String,Object>, so this parser just reads from that map and
the controller routes via ?adapter=mailgun.

Notes:
- Mailgun's 'from' is typically 'Name <email>' — we extract the
  display name portion separately and fall back to the sender
  field for the email. Strips surrounding quotes on the name.
- Mailgun hosts attachment content behind a URL (large
  attachments). We carry the URL through in downloadUrl; a
  follow-up worker can fetch + persist out-of-band.
- Malformed attachments JSON degrades gracefully (empty list).

7 JUnit tests cover core field extraction, threading headers,
provider-hosted attachment parsing, malformed attachments JSON,
sender→from fallback, bare-email (no display name) handling, and
the quote-stripping on display names.
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

Successfully merging this pull request may close these issues.

1 participant