Skip to content

Feature: preview .eml (message/rfc822) attachments like an email#380

Merged
rathlinus merged 1 commit into
bulwarkmail:mainfrom
dealerweb:pr/eml-attachment-preview
Jun 1, 2026
Merged

Feature: preview .eml (message/rfc822) attachments like an email#380
rathlinus merged 1 commit into
bulwarkmail:mainfrom
dealerweb:pr/eml-attachment-preview

Conversation

@dealerweb
Copy link
Copy Markdown
Contributor

Summary

Clicking an .eml attachment (a bounce/DSN, or an email that was forwarded as an attachment) only offered a download. This previews it inline instead, rendered like an email.

Changes

  • New eml preview kind for message/rfc822 / .eml files.
  • FilePreviewModal parses the attachment with postal-mime (dynamic import, so it stays off the main bundle) and renders it via a new EmlPreview component: header (From / To / Subject / Date), the body, and the message's own attachments.
  • The body is shown in a fully sandboxed iframe (sandbox="") on top of DOMPurify (sanitizeEmailHtmlForIframe), so a script-bearing .eml can never execute in our origin.

Type of Change

  • New feature (non-breaking change that adds functionality)

Checklist

  • Contributing Guide read
  • Code follows project style and conventions
  • npm run typecheck && npm run lint passes
  • Build passes (npm run build)
  • Changes tested locally
  • Translations updated (locales/) - n/a, reuses the existing email_viewer labels (no new keys)

Notes for Reviewers

  • No new dependencies (postal-mime is already used by the message viewer) and no new locale keys.
  • Tested on a live Stalwart deployment (a bounce .eml and a forwarded-as-attachment message).

Clicking an embedded email attachment (bounce/DSN, forward-as-attachment, ...)
opened only a download. Add an 'eml' preview kind: FilePreviewModal parses the
blob with postal-mime (dynamic-imported, off the bundle) and renders it via a
new EmlPreview component - header (from/to/subject/date) + body + the message's
own attachments.

The body is sanitized with DOMPurify (sanitizeEmailHtmlForIframe) AND rendered
in a fully-locked sandbox iframe (sandbox="" - no scripts, no same-origin), so a
script-bearing .eml can never execute in-origin. Reuses the email_viewer locale
namespace (no new keys).
@rathlinus rathlinus merged commit 2e4d3d4 into bulwarkmail:main Jun 1, 2026
@dealerweb dealerweb deleted the pr/eml-attachment-preview branch June 1, 2026 15:54
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.

2 participants