Add SMTP attachment support - #124
Conversation
|
|
@diesdasjunge is attempting to deploy a commit to the OpenCore Team on Vercel. A member of the Team first needs to authorize it. |
5c7d893 to
a8f65e6
Compare
| if ( | ||
| typeof attachment.filename !== "string" || | ||
| !/^[\x20-\x21\x23-\x5b\x5d-\x7e]+$/.test(attachment.filename) | ||
| ) { | ||
| throw new EmailValidationError( | ||
| `SMTP attachment filename ${JSON.stringify(attachment.filename)} contains invalid characters.`, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Internationalized filenames are rejected
SMTP attachment validation only permits ASCII filenames, so valid names such as résumé.pdf and 請求書.pdf fail with EmailValidationError before SMTP connects. This prevents delivery of attachments with internationalized filenames. Preserve control-character and MIME-parameter injection protections, but support properly encoded MIME filename parameters with a safe ASCII fallback where appropriate.
Artifacts
SMTP Unicode filename reproduction script
- Runs the actual SDK SMTP send path against an in-process SMTP server and compares an ASCII attachment filename with two Unicode filenames; it proves the Unicode inputs are rejected before connection.
SMTP Unicode filename reproduction output
- Captured output of the focused Bun reproduction command, including its working directory and zero exit status; it shows ASCII send succeeds while both Unicode filenames are rejected before connection.
SMTP validation and MIME implementation output
- Captured numbered source excerpts for the attachment validator and MIME part builder; it shows ASCII-only validation and no encoded filename parameter path.
| const raw = await buildMimeMessage(message, options.defaults, context.idempotencyKey); | ||
| const client = new SmtpClient(options, port, context.idempotencyKey); |
There was a problem hiding this comment.
Attachment loading ignores cancellation
send() builds the entire MIME message without checking or passing context.signal. An aborted send can remain blocked on attachment loading and then transmit the completed message after cancellation. Propagate the signal through MIME construction and file reads, and check it before opening or continuing SMTP delivery.
Artifacts
Executable aborted SMTP attachment reproduction
- This Bun script uses a local SMTP server and delayed FIFO-backed attachment read, aborting at 50ms before releasing the file at 350ms; takeaway: it reproduces SMTP delivery after cancellation.
Aborted SMTP reproduction output
- Captured output for `ABORT_DELAY_MS=50 bun trex-artifacts/smtp-abort-attachment-repro.ts` shows `aborted: true`, `EmailAbortError`, `delivered: true`, and `attachmentEncoded: true`; takeaway: the message was sent after abort.
Greptile SummaryAdds SMTP attachment delivery, multipart MIME construction, attachment validation, test coverage, and documentation updates. Two attachment-delivery failures were reproduced:
Do not merge until SMTP supports safely encoded internationalized filenames and cancellation prevents post-abort delivery. Confidence Score: 3/5
What T-Rex did
|
Why
The built-in SMTP adapter rejected attachments, so it could not serve as a fallback for messages that include files. The original implementation was written before the v1 adapter API and no longer merged cleanly with
main.What changed
multipart/mixedmessages with nestedmultipart/alternativebodies when both text and HTML are present@opencoredev/email-sdkTesting
bun run release:cibun test packages/email-sdk/src/smtp.test.ts packages/email-sdk/src/cli.test.tsbunx oxlinton the touched TypeScript filesgit diff --check