Skip to content

Add plaintext part to multipart emails (#398) - #458

Open
R1MO9 wants to merge 1 commit into
useplunk:nextfrom
R1MO9:fix/398-plaintext-email-part
Open

Add plaintext part to multipart emails (#398)#458
R1MO9 wants to merge 1 commit into
useplunk:nextfrom
R1MO9:fix/398-plaintext-email-part

Conversation

@R1MO9

Copy link
Copy Markdown

Description

Adds a plaintext (text/plain) part alongside the existing HTML part for all outgoing emails, so text-preferring clients get a proper plaintext version instead of HTML-only.

  • SESService.tssendRawEmail now accepts optional text content and emits it as a text/plain part inside the multipart/alternative container, placed before the HTML part (per RFC 2046 ordering). When no text is provided, behavior is unchanged (HTML-only).
  • EmailService.ts — added htmlToText(), a dependency-free HTML→plaintext converter that strips style/script blocks, keeps link URLs next to anchor text (so unsubscribe links survive), converts block elements to line breaks, and decodes entities. Applied to the compiled HTML at send time so the plaintext part carries the same unsubscribe footer as the HTML part.
  • email-processor.ts (live worker) and legacy EmailService.sendEmail — now pass text: htmlToText(compiledHtml).
  • CampaignService.ts — campaign test emails now include the plaintext part too.
  • Docs — added a "Plaintext and HTML in one email" section to the transactional emails concept page.

Type of Change

  • feat: New feature (MINOR version bump)

PR Title Format

feat: add plaintext part to multipart emails

Testing

Added 5 new tests:

  • MIME structure verification (plaintext part appears before HTML part; omitted when no text is provided)
  • Unit tests for htmlToText()

All 49 tests in the file pass locally.

Checklist

  • PR title follows conventional commits format
  • Code builds successfully
  • Tests pass locally
  • Documentation updated (if needed)

Related Issues

Closes#398

Sign up for freeto 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.

Support for Plaintext and HTML Emails in one Email

1 participant

@R1MO9