@prunellejs/mail 0.1.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms.txt CHANGED
@@ -1,10 +1,14 @@
1
1
  # @prunellejs/mail Reference
2
2
 
3
- > Zero-dependency email delivery (Resend HTTP or custom transport) with a dev-only HTML/JSON outbox preview.
3
+ > Zero-dependency email delivery with JSX/TSX templates (auto HTML + plain text), email-safe components, native SMTP/SMTPS/STARTTLS, Resend, Postmark, `MAIL_URL`, `@prunellejs/jobs` retry integration, and a dev-only outbox + template preview.
4
4
 
5
5
  ## Imports
6
6
 
7
- - `@prunellejs/mail`: `createMailer`, `resend`, `MailNotConfiguredError`; types `Mailer`, `MailerOptions`, `MailPreviewOptions`, `MailMessage`, `SentMail`, `MailAddress`, `MailTransport`.
7
+ - `@prunellejs/mail`:
8
+ - Core: `createMailer`, `renderMail`, `htmlToText`, `MailNotConfiguredError`
9
+ - Transports: `smtp`, `resend`, `postmark`, `transportFromUrl`, `buildMimeMessage`, `dotStuffSmtpData`
10
+ - Components: `Email`, `Section`, `Heading`, `Text`, `Button`, `Divider`, `Footer`, `Link`
11
+ - Types: `Mailer`, `MailerOptions`, `MailPreviewOptions`, `MailPreviewEntry`, `MailPreviewRegisterOptions`, `MailRetryOptions`, `MailMessage`, `MailBody`, `RenderedMail`, `RenderedMailPreview`, `SentMail`, `MailAddress`, `MailTransport`, `SmtpOptions`, `ResendOptions`, `PostmarkOptions`, `EmailProps`, `SectionProps`, `HeadingProps`, `TextProps`, `ButtonProps`, `DividerProps`, `FooterProps`, `LinkProps`, `TextAlign`.
8
12
 
9
13
  ## Setup (`createMailer(options?)`)
10
14
 
@@ -12,34 +16,61 @@
12
16
 
13
17
  - `from`: default sender (`string | { name, address }`, falls back to `process.env.MAIL_FROM`, then `'noreply@localhost'` outside production: a production start refuses without one).
14
18
  - `to`: default recipient(s) (falls back to `process.env.MAIL_TO`); `send()` with no recipient throws, in every mode.
15
- - A production start refuses with no transport (`transport` or `RESEND_API_KEY`) unless `optional: true`.
16
- - `transport`: `MailTransport` (`{ send(mail: SentMail): Promise<void> }`). Defaults to `resend()` when `process.env.RESEND_API_KEY` is set.
19
+ - `transport`: `MailTransport` (`{ send(mail: SentMail): Promise<void> }`). Resolution order:
20
+ 1. Explicit `options.transport`
21
+ 2. `process.env.MAIL_URL` (`smtp://`, `smtps://`, `resend://`, `postmark://`)
22
+ 3. `process.env.RESEND_API_KEY` (`resend()`)
23
+ - A production start refuses with no transport (`transport`, `MAIL_URL`, or `RESEND_API_KEY`) unless `optional: true`.
17
24
  - `optional`: when `false`/omitted, calling `send()` in `NODE_ENV=production` without a transport throws `MailNotConfiguredError`.
18
25
  - `previewRoute`: dev outbox URL (default `'/_pru/mail'`). `preview: false` disables the preview.
26
+ - `previews`: array of `{ name, subject?, props?, render: () => MailBody }` templates rendered live in the dev outbox. You can also register previews imperatively via `mail.preview(name, Component, sampleProps, { subject? })` or `mail.preview(name, () => <Welcome ... />, { subject? })`.
27
+ - `retries`: `{ queue?: string, attempts?: number, backoff?: 'exponential' | 'fixed' | number }` used when `@prunellejs/jobs` (`JOBS_SERVICE`) is registered. On transport failure, delivery is enqueued on `mail.deliver` with `{ key: record.id }` for durable deduplicated retries. Set `asyncQueue: true` to enqueue upfront without attempting inline send first.
19
28
 
20
- ## Mounted Routes (dev/test only — never in production)
29
+ ## JSX/TSX Templates & Components
21
30
 
22
- - `GET /_pru/mail` — HTML outbox viewer (HTML bodies rendered in sandboxed `<iframe>`s).
23
- - `GET /_pru/mail.json` — `{ count, messages }` JSON dump of captured messages (up to 100 in memory; production keeps no copy).
31
+ - `await mail.send({ to, subject, body: <Welcome name="Ada" /> })` renders both `html` and a clean `text` alternative automatically (explicit `text` or `html` overrides the rendered part).
32
+ - `await renderMail(node)` returns `{ html, text }` from any JSX/TSX element, compiled `Html`, async component result, or render factory.
33
+ - Built-in email-safe components work identically in compiled Prunelle routes and direct Bun execution:
34
+ - `Email({ lang?, title?, preview?, backgroundColor?, containerBackgroundColor?, width?, children })` — full HTML email document with Outlook MSO namespaces & DPI XML, dark-mode `<meta>` + `@media (prefers-color-scheme: dark)` CSS, hidden preheader, and centered 600px table layout.
35
+ - `Section`, `Heading` (`h1`–`h3`), `Text` (`muted?`), `Button` (Outlook VML roundrect + dark-mode CTA), `Divider`, `Footer`, `Link`.
24
36
 
25
- ## Handle & Transport API
37
+ ## Transports & `MAIL_URL`
26
38
 
27
- - `await mail.send({ from?, to?, replyTo?, subject, text?, html? })` → `SentMail` (`{ id, from, to, replyTo?, subject, text?, html?, sentAt }`).
28
- - `mail.isConfigured()`: `boolean`. `mail.outbox`: `SentMail[]`. `mail.clearOutbox()`.
29
- - `resend({ apiKey?, endpoint?, timeoutMs?, retries? })`: built-in Resend HTTP transport using `fetch()`. Each request times out after `timeoutMs` (10 000). A `429` or `5xx` answer is retried `retries` times (2), after its `retry-after` or 0.5 s doubling, capped at 5 s, under the mail's id as `Idempotency-Key`, so a retry never sends twice.
30
- - Works directly as `createAuth({ mailer: mail })` with `@prunellejs/auth`.
39
+ - `transportFromUrl(url)` supports:
40
+ - `smtp://[user:pass@]host[:port]` (default port 587; upgrades via `STARTTLS` when advertised, `?tls=true`/`?starttls=true` to require, `?tls=false` to disable, `?allowInsecureAuth=true` to allow plaintext `AUTH` on non-loopback hosts)
41
+ - `smtps://[user:pass@]host[:port]` (default port 465; implicit TLS)
42
+ - `resend://<apiKey>` or `resend://:<apiKey>@api.resend.com`
43
+ - `postmark://<serverToken>` or `postmark://:<serverToken>@api.postmarkapp.com`
44
+ - `smtp(options)` uses `Bun.connect` TCP/TLS sockets directly (zero npm dependencies): RFC 5321 multi-line parsing, `EHLO`, `STARTTLS` (with RFC 3207 response-injection protection and plaintext credential downgrade refusal on non-loopback hosts unless `allowInsecureAuth: true` or `requireTls: false`), `AUTH PLAIN` / `AUTH LOGIN`, `MAIL FROM`, `RCPT TO`, `DATA` with CRLF normalization + dot-stuffing, MIME `multipart/alternative`, and `QUIT`.
45
+ - `resend({ apiKey?, endpoint?, timeoutMs?, retries? })` and `postmark({ serverToken?, endpoint?, timeoutMs?, retries?, messageStream? })` use native `fetch()` with timeout and retries on `429`/`5xx` and transient network/timeout errors.
46
+
47
+ ## Mounted Routes (`prunelle dev` or `NODE_ENV=test` only — never in production or built servers outside test)
48
+
49
+ - `GET /_pru/mail` — HTML outbox viewer showing registered template previews (HTML iframe + plain text) and sent messages (sandboxed `<iframe>`s + plain text).
50
+ - `GET /_pru/mail.json` — `{ count, messages, previews }` JSON dump (up to 100 sent messages in memory; production keeps no copy).
31
51
 
32
52
  ## Snippet
33
53
 
34
- ```ts
35
- // src/mail.ts (and register `plugins: [mail]` in prunelle.config.ts)
36
- import { createMailer, resend } from '@prunellejs/mail'
54
+ ```tsx
55
+ // src/mail.tsx (and register `plugins: [mail]` in prunelle.config.ts)
56
+ import { Button, createMailer, Email, Footer, Heading, Text } from '@prunellejs/mail'
57
+
58
+ export function Welcome({ name }: { name: string }) {
59
+ return (
60
+ <Email preview="Welcome aboard">
61
+ <Heading>Welcome, {name}!</Heading>
62
+ <Text>Your account is ready.</Text>
63
+ <Button href="https://example.com/start">Get started</Button>
64
+ <Footer>Acme Inc.</Footer>
65
+ </Email>
66
+ )
67
+ }
37
68
 
38
69
  export const mail = createMailer({
39
70
  from: 'App <noreply@example.com>',
40
- transport: process.env.RESEND_API_KEY ? resend() : undefined,
71
+ previews: [{ name: 'Welcome', subject: 'Welcome!', render: () => <Welcome name="Ada" /> }],
41
72
  })
42
73
 
43
- // In an action or route:
44
- await mail.send({ to: 'ada@example.com', subject: 'Welcome', text: 'Hello!' })
74
+ // In an action or route (uses MAIL_URL or RESEND_API_KEY automatically):
75
+ await mail.send({ to: 'ada@example.com', subject: 'Welcome!', body: <Welcome name="Ada" /> })
45
76
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@prunellejs/mail",
3
- "version": "0.1.1",
4
- "description": "Zero-dependency email delivery (Resend / custom transport) and dev outbox plugin for Prunelle",
3
+ "version": "0.5.2",
4
+ "description": "Zero-dependency email delivery (JSX/TSX templates, SMTP/SMTPS, Resend, Postmark, MAIL_URL, @prunellejs/jobs retries) and dev outbox/preview plugin for Prunelle",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -21,6 +21,6 @@
21
21
  "directory": "packages/plugin-mail"
22
22
  },
23
23
  "peerDependencies": {
24
- "prunelle": "^0.1.1"
24
+ "prunelle": "^0.5.2"
25
25
  }
26
26
  }
@@ -0,0 +1,255 @@
1
+ // Email-safe JSX/TSX components with table layouts, inline styles, Outlook MSO VML fallbacks, and dark-mode CSS.
2
+ // Built with `raw`/`esc`/`escAttr` from `prunelle/server` so they render identically both in compiled Prunelle routes and direct Bun execution.
3
+
4
+ import type { Html, PrunelleChild } from 'prunelle/jsx-runtime'
5
+ import { esc, escAttr, raw } from 'prunelle/server'
6
+
7
+ export type TextAlign = 'left' | 'center' | 'right'
8
+
9
+ export interface EmailProps {
10
+ /** Document language attribute (default `'en'`). */
11
+ lang?: string | undefined
12
+ /** Optional `<title>` inside `<head>`. */
13
+ title?: string | undefined
14
+ /** Hidden inbox preheader text (excluded from auto-derived plain text). */
15
+ preview?: string | undefined
16
+ /** Outer email canvas background color (default `'#f4f4f5'`). */
17
+ backgroundColor?: string | undefined
18
+ /** Inner card background color (default `'#ffffff'`). */
19
+ containerBackgroundColor?: string | undefined
20
+ /** Max container width in pixels (default `600`). */
21
+ width?: number | undefined
22
+ children?: PrunelleChild | undefined
23
+ }
24
+
25
+ export interface SectionProps {
26
+ padding?: string | undefined
27
+ backgroundColor?: string | undefined
28
+ align?: TextAlign | undefined
29
+ style?: string | undefined
30
+ children?: PrunelleChild | undefined
31
+ }
32
+
33
+ export interface HeadingProps {
34
+ as?: 'h1' | 'h2' | 'h3' | undefined
35
+ align?: TextAlign | undefined
36
+ style?: string | undefined
37
+ children?: PrunelleChild | undefined
38
+ }
39
+
40
+ export interface TextProps {
41
+ align?: TextAlign | undefined
42
+ muted?: boolean | undefined
43
+ style?: string | undefined
44
+ children?: PrunelleChild | undefined
45
+ }
46
+
47
+ export interface ButtonProps {
48
+ href: string
49
+ backgroundColor?: string | undefined
50
+ color?: string | undefined
51
+ borderRadius?: number | undefined
52
+ align?: TextAlign | undefined
53
+ style?: string | undefined
54
+ children?: PrunelleChild | undefined
55
+ }
56
+
57
+ export interface DividerProps {
58
+ color?: string | undefined
59
+ margin?: string | undefined
60
+ style?: string | undefined
61
+ }
62
+
63
+ export interface FooterProps {
64
+ align?: TextAlign | undefined
65
+ style?: string | undefined
66
+ children?: PrunelleChild | undefined
67
+ }
68
+
69
+ export interface LinkProps {
70
+ href: string
71
+ color?: string | undefined
72
+ style?: string | undefined
73
+ children?: PrunelleChild | undefined
74
+ }
75
+
76
+ const SAFE_URL_SCHEME_RE = /^(?:https?:|mailto:|tel:|\/|#)/i
77
+ const HAS_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i
78
+
79
+ const EMAIL_HEAD_CSS = [
80
+ ':root{color-scheme:light dark;supported-color-schemes:light dark;}',
81
+ 'body{margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}',
82
+ 'table,td{border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;}',
83
+ 'img{border:0;height:auto;line-height:100%;outline:none;text-decoration:none;}',
84
+ '@media (prefers-color-scheme: dark){',
85
+ '.pru-email-bg{background-color:#09090b!important;color:#f4f4f5!important;}',
86
+ '.pru-email-card{background-color:#18181b!important;border-color:#27272a!important;}',
87
+ '.pru-email-heading,.pru-email-text{color:#f4f4f5!important;}',
88
+ '.pru-email-muted{color:#a1a1aa!important;}',
89
+ '.pru-email-divider{border-top-color:#27272a!important;}',
90
+ '.pru-email-link{color:#60a5fa!important;}',
91
+ '.pru-email-btn{background-color:#f4f4f5!important;color:#09090b!important;}',
92
+ '}',
93
+ '[data-ogsc] .pru-email-bg{background-color:#09090b!important;color:#f4f4f5!important;}',
94
+ '[data-ogsc] .pru-email-card{background-color:#18181b!important;border-color:#27272a!important;}',
95
+ '[data-ogsc] .pru-email-heading,[data-ogsc] .pru-email-text{color:#f4f4f5!important;}',
96
+ '[data-ogsc] .pru-email-muted{color:#a1a1aa!important;}',
97
+ '[data-ogsc] .pru-email-link{color:#60a5fa!important;}',
98
+ '@media only screen and (max-width:620px){.pru-email-pad{padding:24px 16px!important;}}',
99
+ ].join('')
100
+
101
+ const HEADING_STYLES: Readonly<Record<'h1' | 'h2' | 'h3', string>> = {
102
+ h1: 'margin:0 0 16px;font-size:24px;line-height:1.3;font-weight:700;color:#18181b;',
103
+ h2: 'margin:0 0 12px;font-size:20px;line-height:1.35;font-weight:700;color:#18181b;',
104
+ h3: 'margin:0 0 8px;font-size:16px;line-height:1.4;font-weight:600;color:#18181b;',
105
+ }
106
+
107
+ const PREVIEW_SPACER = '&zwnj;&nbsp;'.repeat(24)
108
+
109
+ function safeEmailUrl(href: string, component: string): string {
110
+ const trimmed = href.trim()
111
+ if (HAS_SCHEME_RE.test(trimmed) && !SAFE_URL_SCHEME_RE.test(trimmed))
112
+ throw new RangeError(`@prunellejs/mail: <${component}> refused unsafe URL "${href}"`)
113
+ return trimmed
114
+ }
115
+
116
+ function appendExtraStyle(base: string, extra?: string): string {
117
+ if (!extra)
118
+ return base
119
+ const normalized = extra.trim()
120
+ if (normalized.length === 0)
121
+ return base
122
+ return base.endsWith(';') ? `${base}${normalized}` : `${base};${normalized}`
123
+ }
124
+
125
+ function safeAlign(align?: TextAlign): TextAlign {
126
+ return align === 'center' || align === 'right' ? align : 'left'
127
+ }
128
+
129
+ /** Root HTML email document with Outlook MSO namespaces/DPI settings, dark-mode meta + CSS, and centered 600px table container. */
130
+ export function Email(props: EmailProps = {}): Html {
131
+ const lang = props.lang ?? 'en'
132
+ const bg = props.backgroundColor ?? '#f4f4f5'
133
+ const cardBg = props.containerBackgroundColor ?? '#ffffff'
134
+ const width = props.width ?? 600
135
+ const titleTag = props.title !== undefined ? `<title>${esc(props.title)}</title>` : ''
136
+ const previewBlock = props.preview !== undefined
137
+ ? `<div data-pru-preview style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0;font-size:1px;">${esc(props.preview)}${PREVIEW_SPACER}</div>`
138
+ : ''
139
+
140
+ return raw(
141
+ `<!DOCTYPE html>`
142
+ + `<html lang="${escAttr(lang)}" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">`
143
+ + `<head>`
144
+ + `<meta charset="utf-8">`
145
+ + `<meta name="viewport" content="width=device-width,initial-scale=1">`
146
+ + `<meta http-equiv="X-UA-Compatible" content="IE=edge">`
147
+ + `<meta name="x-apple-disable-message-reformatting">`
148
+ + `<meta name="color-scheme" content="light dark">`
149
+ + `<meta name="supported-color-schemes" content="light dark">`
150
+ + titleTag
151
+ + `<!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]-->`
152
+ + `<style>${EMAIL_HEAD_CSS}</style>`
153
+ + `</head>`
154
+ + `<body class="pru-email-bg" style="margin:0;padding:0;background-color:${escAttr(bg)};color:#18181b;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;">`
155
+ + previewBlock
156
+ + `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="pru-email-bg" style="background-color:${escAttr(bg)};width:100%;margin:0;padding:24px 0;">`
157
+ + `<tr><td align="center" style="padding:0 12px;">`
158
+ + `<!--[if mso]><table role="presentation" align="center" border="0" cellspacing="0" cellpadding="0" width="${width}"><tr><td width="${width}"><![endif]-->`
159
+ + `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="pru-email-card" style="max-width:${width}px;width:100%;margin:0 auto;background-color:${escAttr(cardBg)};border-radius:8px;border:1px solid #e4e4e7;overflow:hidden;">`
160
+ + `<tr><td class="pru-email-pad" style="padding:32px 28px;">${esc(props.children)}</td></tr>`
161
+ + `</table>`
162
+ + `<!--[if mso]></td></tr></table><![endif]-->`
163
+ + `</td></tr></table>`
164
+ + `</body></html>`,
165
+ )
166
+ }
167
+
168
+ /** Table-based email layout section with inline padding and optional background color. */
169
+ export function Section(props: SectionProps = {}): Html {
170
+ const align = safeAlign(props.align)
171
+ let tdStyle = `padding:${props.padding ?? '8px 0'};`
172
+ if (props.backgroundColor !== undefined)
173
+ tdStyle += `background-color:${props.backgroundColor};`
174
+ tdStyle = appendExtraStyle(tdStyle, props.style)
175
+
176
+ return raw(
177
+ `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;">`
178
+ + `<tr><td align="${align}" style="${escAttr(tdStyle)}">${esc(props.children)}</td></tr>`
179
+ + `</table>`,
180
+ )
181
+ }
182
+
183
+ /** Email-safe heading (`h1`–`h3`) with inline typography and dark-mode class. */
184
+ export function Heading(props: HeadingProps = {}): Html {
185
+ const tag = props.as === 'h2' || props.as === 'h3' ? props.as : 'h1'
186
+ let style = HEADING_STYLES[tag]
187
+ if (props.align !== undefined)
188
+ style += `text-align:${safeAlign(props.align)};`
189
+ style = appendExtraStyle(style, props.style)
190
+ return raw(`<${tag} class="pru-email-heading" style="${escAttr(style)}">${esc(props.children)}</${tag}>`)
191
+ }
192
+
193
+ /** Email-safe paragraph with readable line height, inline styles, and optional muted tone. */
194
+ export function Text(props: TextProps = {}): Html {
195
+ const cls = props.muted ? 'pru-email-muted' : 'pru-email-text'
196
+ const color = props.muted ? '#71717a' : '#27272a'
197
+ let style = `margin:0 0 16px;font-size:15px;line-height:1.6;color:${color};`
198
+ if (props.align !== undefined)
199
+ style += `text-align:${safeAlign(props.align)};`
200
+ style = appendExtraStyle(style, props.style)
201
+ return raw(`<p class="${cls}" style="${escAttr(style)}">${esc(props.children)}</p>`)
202
+ }
203
+
204
+ /** Bulletproof Outlook VML + dark-mode CTA button. */
205
+ export function Button(props: ButtonProps): Html {
206
+ const href = safeEmailUrl(props.href, 'Button')
207
+ const bg = props.backgroundColor ?? '#18181b'
208
+ const color = props.color ?? '#ffffff'
209
+ const radius = props.borderRadius ?? 6
210
+ const align = safeAlign(props.align)
211
+ const arcsize = Math.min(50, Math.max(0, Math.round((radius / 44) * 100)))
212
+ const label = esc(props.children)
213
+ const linkStyle = appendExtraStyle(
214
+ `display:inline-block;padding:12px 24px;background-color:${bg};color:${color};font-size:15px;font-weight:600;line-height:1.2;text-decoration:none;border-radius:${radius}px;mso-hide:all;`,
215
+ props.style,
216
+ )
217
+
218
+ return raw(
219
+ `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;margin:20px 0;">`
220
+ + `<tr><td align="${align}">`
221
+ + `<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${escAttr(href)}" style="height:44px;v-text-anchor:middle;width:220px;" arcsize="${arcsize}%" stroke="f" fillcolor="${escAttr(bg)}"><w:anchorlock/><center style="color:${escAttr(color)};font-family:sans-serif;font-size:15px;font-weight:600;">${label}</center></v:roundrect><![endif]-->`
222
+ + `<!--[if !mso]><!--><a href="${escAttr(href)}" class="pru-email-btn" style="${escAttr(linkStyle)}">${label}</a><!--<![endif]-->`
223
+ + `</td></tr></table>`,
224
+ )
225
+ }
226
+
227
+ /** Horizontal rule styled for email clients and dark mode. */
228
+ export function Divider(props: DividerProps = {}): Html {
229
+ const color = props.color ?? '#e4e4e7'
230
+ const margin = props.margin ?? '24px 0'
231
+ const style = appendExtraStyle(`border:0;border-top:1px solid ${color};margin:${margin};`, props.style)
232
+ return raw(`<hr class="pru-email-divider" style="${escAttr(style)}">`)
233
+ }
234
+
235
+ /** Muted footer section separated by a top border. */
236
+ export function Footer(props: FooterProps = {}): Html {
237
+ const align = safeAlign(props.align)
238
+ const tdStyle = appendExtraStyle(
239
+ 'padding-top:16px;font-size:12px;line-height:1.5;color:#71717a;',
240
+ props.style,
241
+ )
242
+ return raw(
243
+ `<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="pru-email-divider" style="width:100%;margin-top:24px;border-top:1px solid #e4e4e7;">`
244
+ + `<tr><td align="${align}" class="pru-email-muted" style="${escAttr(tdStyle)}">${esc(props.children)}</td></tr>`
245
+ + `</table>`,
246
+ )
247
+ }
248
+
249
+ /** Styled inline hyperlink for email bodies. */
250
+ export function Link(props: LinkProps): Html {
251
+ const href = safeEmailUrl(props.href, 'Link')
252
+ const color = props.color ?? '#2563eb'
253
+ const style = appendExtraStyle(`color:${color};text-decoration:underline;`, props.style)
254
+ return raw(`<a href="${escAttr(href)}" class="pru-email-link" style="${escAttr(style)}">${esc(props.children)}</a>`)
255
+ }