@dbx-tools/shared-email
Browser-safe email sending schemas and inferred types.
Import this package when a UI, Mastra tool schema, server route, or test needs
to validate the same email payloads that
@dbx-tools/email sends.
Key features:
- Shared
EmailMessagecontract for generated email drafts and direct sends. - Attachment schema that supports inline content, file paths, URLs, encoding, and content-type hints.
- Send-result schema for SMTP and outbox responses.
- Sender-options schema for AppKit routes that expose allowed
Fromvalues to a browser client. - Model/tool-friendly schemas that avoid JSON Schema constraints known to cause problems with some serving endpoints.
Validate A Drafted Message
Section titled “Validate A Drafted Message”import { email, type EmailMessage } from "@dbx-tools/shared-email";
const message: EmailMessage = email.emailMessageSchema.parse({ to: ["alice@example.com"], subject: "Report", body: "# Done\nThe report is attached.", attachments: [{ filename: "report.csv", content: "a,b\n1,2\n" }],});The message schema covers recipients, subject, body content, and attachments. Attachments can carry inline content, a local path, a URL, encoding metadata, and content type hints.
Validate Send Results
Section titled “Validate Send Results”const result = email.emailResultSchema.parse(await sendResponse.json());emailResultSchema is the shared shape for SMTP sends and outbox writes. Use it
for approval UI state and test assertions.
Render Sender Choices
Section titled “Render Sender Choices”const senders = email.emailSendersSchema.parse( await fetch("/api/email/senders").then((r) => r.json()),);The sender schema describes the concrete From choices for the current user,
the default sender, and whether the list is restricted by policy.
Modules
Section titled “Modules”email-emailAttachmentSchema,emailMessageSchema,emailResultSchema,emailSendersSchema, and flat inferred types:EmailAttachment,EmailMessage,EmailResult, andEmailSenders. The schemas intentionally avoid array.min()constraints so they can be reused as model/tool JSON schemas for serving endpoints that rejectminItems.
Passwordless authentication contracts live in
@dbx-tools/shared-auth.