Repository navigation
v0.3.0
Minor Changes
-
5b43735: Give layouts the text direction of the email as
LayoutContext.dir.diris'rtl'for languages written right to left, such as Arabic and Hebrew, and'ltr'otherwise. Set it as thedirattribute of your layout's markup.diris required, so code that builds aLayoutContextby hand, such as a unit test of a custom layout, needs it too. Layouts passed tocreateMailerneed no change.- Migration: add
dirwhere you build aLayoutContextyourself, for exampledefaultLayout({ ...context, dir: 'ltr' })or{ branding, theme, locale: 'en', dir: 'ltr', subject, preheader, content, messages }.
-
f9a5407: Remove the
UiMessagestype from the public exports.- No exported function or type uses it, so it described nothing users can pass or receive.
- Migration: if you import
UiMessages, replace it with{ readonly linkFallback: string }.
-
f9a5407: Rename the
ctaUrlprop of thewelcometemplate tostartUrl.WelcomePropshasstartUrlinstead ofctaUrl: an absolutehttp:orhttps:link behind the "Get started" button,branding.appUrlby default. The name follows the other link props, which are named after their action (verifyUrl,resetUrl,signInUrl).sendandrenderrejectctaUrlwithINVALID_PROPS.- Migration: replace
props: { ctaUrl }withprops: { startUrl }inmailer.send('welcome', …)andmailer.render('welcome', …).
Patch Changes
-
f9a5407: Remove the unused
zodimport from the type declarations.- Type checking a project that uses the package does not load zod's declarations through it. zod stays a runtime dependency.
- No exported type changes.
-
f9a5407: Document the semver policy of the
MailerErrorCodetype: codes can be added in a minor release.- A
switchovererror.codeneeds adefaultbranch. Existing codes keep their meaning.
- A
-
f9a5407: Make
instanceof MailerErrorwork across the ESM and CommonJS builds.- When an app loads both builds, for example an ESM app with a CommonJS dependency that also uses the package,
error instanceof MailerErrorholds for errors from either build. instanceofagainst your own subclass ofMailerErrormatches only instances of that subclass.
- When an app loads both builds, for example an ESM app with a CommonJS dependency that also uses the package,
-
33827e1: Add a Resend transport:
resendTransportfrom@onetodone/mailer/resend.resendTransport({ apiKey, baseUrl?, fetch? })sends through the Resend API with the built-infetchand needs no extra package.- Every field of the email is sent, including cc, bcc, reply-to, headers and attachments. Attachments with a
cidgo out as inline images. sendresolves with the Resend email ID asmessageId.- A failed delivery rejects with
TRANSPORT_FAILED, with the HTTP status instatusand Resend's error response incause.retryableistruefor a rate limit or quota, a conflict, a server error or a network failure, andfalsefor any other 4xx. - Invalid settings throw
INVALID_CONFIG; the API key never appears in the message.
-
33827e1: Tell retryable delivery failures from rejected emails through
MailerError.retryableandMailerError.status.retryableistruewhen the same email may be delivered on a later attempt,falsewhen another attempt fails the same way, andundefinedwhen unknown.statusholds the SMTP reply code or the HTTP status of the provider's API when the provider answered.smtpTransportsets them onTRANSPORT_FAILED: a 4xx reply, a lost connection or a timeout is retryable, a 5xx reply is not.- Your own transport can set them by throwing
new MailerError('TRANSPORT_FAILED', message, { cause, retryable, status }); theMailerErrorOptionstype describes the options. - The meaning of
TRANSPORT_FAILEDis unchanged, and errors your transport throws without these fields keep themundefined.
-
5b43735: Render emails in right-to-left languages, such as Arabic and Hebrew, right to left.
- The direction follows the email's locale. For a right-to-left locale the built-in layout sets
dir="rtl"and aligns the content to the right, and Outlook on Windows aligns buttons, codes and images to the right too. - Codes from
ui.codeand the link fromui.linkFallbackstay left to right inside right-to-left text, so123 456keeps its order. - Templates receive the direction as
dir('ltr'or'rtl') next tolocale, for markup of their own. - Emails in left-to-right languages render exactly as before.
- The direction follows the email's locale. For a right-to-left locale the built-in layout sets