Skip to content

Expose MIME/EML composition without sending a message #68

Description

@gerardp

Provide a public API that composes an Upyo Message into complete MIME/EML content without connecting to SMTP or delivering it.

This complements raw SMTP delivery in #64:

Message -> MIME/EML: compose, inspect, archive
MIME/EML -> SMTP: deliver

Applications could inspect generated headers and attachments, save an .eml, or pass the composed message to another delivery system. Calendar composition from #63 would also become easier to inspect once supported.

Existing foundation

At commit 0aa1111fd16c2cf3881769add76b79b178d374e0, message-converter.ts already contains convertMessage() and prepareMessage(). The former returns an envelope and a complete raw string; the latter prepares headers and a streaming body. Neither is exposed by the package entry point.

The proposal is to reuse this composition path through a supported public API, without requiring consumers to import private files or maintain another MIME composer.

Proposed scope

  • Accept a structured Message and return complete MIME content suitable for saving as an .eml, with the SMTP envelope available separately.
  • Require no SMTP host, credentials, connection, or delivery attempt.
  • Offer streaming output so large attachments do not require buffering the entire message. Callers can collect the output when they need bytes in memory.
  • Preserve the existing composition behavior for headers, text/HTML, attachments, and optional DKIM signing. Document the treatment of Bcc and generated Message-ID/Date values.
  • Keep SMTP dot-stuffing and the DATA terminator out of the exported MIME; those belong to transmission.
  • Respect AbortSignal and close attachment readers when consumption fails or stops early.

The function name, return shape, and export location are open for discussion. A small public composition API is sufficient; a new plugin framework or a duplicate composer is not needed.

Nodemailer's stream transport provides a reference for generating a complete message without delivering it.

Suggested validation

Parse exported MIME to verify headers, multipart structure, and decoded attachment bytes; cover configured DKIM signing, streaming cancellation, and early consumer exit. Ensure composition does not open an SMTP connection and continues to share the production composition path.

This is a feature request based on source inspection; no implementation or runtime validation of a new export API is claimed.

AI assistance: Codex checked the existing compositor and helped draft this request from the reporter's reviewed proposal.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions