@fabrika/email 0.9.0-dev.16 → 0.9.0-dev.18
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/package.json +6 -1
- package/src/brevo.ts +158 -0
- package/src/conformance.ts +14 -0
- package/src/email.ts +2 -0
- package/src/providers.ts +3 -0
- package/src/validation.ts +8 -5
- package/types/src/brevo.d.ts +19 -0
- package/types/src/email.d.ts +2 -0
- package/types/src/providers.d.ts +2 -0
- package/types/src/validation.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/email",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"types": "./types/src/ahasend.d.ts",
|
|
37
37
|
"default": "./src/ahasend.ts"
|
|
38
38
|
},
|
|
39
|
+
"./brevo": {
|
|
40
|
+
"bun": "./src/brevo.ts",
|
|
41
|
+
"types": "./types/src/brevo.d.ts",
|
|
42
|
+
"default": "./src/brevo.ts"
|
|
43
|
+
},
|
|
39
44
|
"./cloudflare": {
|
|
40
45
|
"bun": "./src/cloudflare.ts",
|
|
41
46
|
"types": "./types/src/cloudflare.d.ts",
|
package/src/brevo.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Brevo's transactional email API (https://developers.brevo.com/reference/sendtransacemail), built from its
|
|
2
|
+
// documentation in November 2026 and checked only against a stubbed fetch (backlog 290). A 201 carries the message id.
|
|
3
|
+
// Brevo dedupes a repeated `idempotencyKey` for 30 minutes only, while a relay or an outbox retries for hours, so the
|
|
4
|
+
// adapter sends the key but does not report itself idempotent: an unknown outcome over Brevo waits for a person.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod'
|
|
7
|
+
import { type EmailProvider, parseProviderVariables } from './config.js'
|
|
8
|
+
import { base64Of } from './content.js'
|
|
9
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js'
|
|
10
|
+
import { credentialVariable, type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions, isCredential } from './http-sender.js'
|
|
11
|
+
import type { ProviderResponse } from './http.js'
|
|
12
|
+
|
|
13
|
+
const BREVO_SEND_URL = 'https://api.brevo.com/v3/smtp/email'
|
|
14
|
+
const brevoSuccessSchema = z.object({ messageId: z.string() })
|
|
15
|
+
/** A refusal's `code` is one of a documented set; its `message` is free text and is never read. */
|
|
16
|
+
const brevoErrorSchema = z.object({ code: z.string() })
|
|
17
|
+
/** Brevo bounds a sender's or a recipient's display name at 70 characters; the contract allows 128. */
|
|
18
|
+
const BREVO_MAX_NAME_LENGTH = 70
|
|
19
|
+
/**
|
|
20
|
+
* Brevo bounds a transactional message at 20 MB with its attachments base64; 10 MiB of bytes leaves room for the
|
|
21
|
+
* bodies. Its help center also mentions 4 MB per file, which is not enforced here (backlog 290).
|
|
22
|
+
*/
|
|
23
|
+
const BREVO_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024
|
|
24
|
+
/**
|
|
25
|
+
* The extensions Brevo takes an attachment with, from its API reference. It takes no media type: it derives it from the
|
|
26
|
+
* file name, so the adapter refuses any other file before the request instead of losing the message to a 400.
|
|
27
|
+
*/
|
|
28
|
+
const BREVO_ATTACHMENT_EXTENSIONS: readonly string[] = (
|
|
29
|
+
'xlsx xls ods docx docm doc csv pdf txt gif jpg jpeg png tif tiff rtf bmp cgm css shtml html htm zip xml ppt pptx tar ez ics mobi msg pub '
|
|
30
|
+
+ 'eps odt mp3 m4a m4v wma ogg flac wav aif aifc aiff mp4 mov avi mkv mpeg mpg wmv pkpass xlsm'
|
|
31
|
+
).split(' ')
|
|
32
|
+
/**
|
|
33
|
+
* A repeated idempotency key (`duplicate_parameter`), an identical request too soon (`duplicate_request`), or a request
|
|
34
|
+
* the reference's error codes call already processed: each says an earlier request may have sent the message.
|
|
35
|
+
*/
|
|
36
|
+
const DUPLICATE_CODES: ReadonlySet<string> = new Set(['duplicate_parameter', 'duplicate_request', 'Request already processed'])
|
|
37
|
+
/** The account has no credits left (402 `not_enough_credits`; the reference also lists `Insufficient credits`). */
|
|
38
|
+
const NO_CREDITS_CODES: ReadonlySet<string> = new Set(['not_enough_credits', 'Insufficient credits'])
|
|
39
|
+
/**
|
|
40
|
+
* The key or the account may not send: a failed authentication, an unknown key, a missing permission, an account still
|
|
41
|
+
* validated. The reference lists `Authentication failed` and `api-key not found` beside the snake_case codes.
|
|
42
|
+
*/
|
|
43
|
+
const NOT_ALLOWED_CODES: ReadonlySet<string> = new Set([
|
|
44
|
+
'unauthorized',
|
|
45
|
+
'Authentication failed',
|
|
46
|
+
'api-key not found',
|
|
47
|
+
'permission_denied',
|
|
48
|
+
'account_under_validation',
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
export interface BrevoEmailSenderOptions extends HttpEmailSenderOptions {
|
|
52
|
+
/** An API key (v3) of the account. */
|
|
53
|
+
readonly apiKey: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class BrevoEmailSender extends HttpEmailSender {
|
|
57
|
+
readonly capabilities: EmailSenderCapabilities = {
|
|
58
|
+
// Brevo keeps a key for 30 minutes, shorter than any retry horizon here, so a late retry could deliver twice.
|
|
59
|
+
idempotent: false,
|
|
60
|
+
confirmation: 'sync',
|
|
61
|
+
maxBatch: 1,
|
|
62
|
+
maxAttachmentBytes: BREVO_MAX_ATTACHMENT_BYTES,
|
|
63
|
+
attachmentExtensions: BREVO_ATTACHMENT_EXTENSIONS,
|
|
64
|
+
// No `listUnsubscribe`, and so no `broadcast`: Brevo takes no standard header in `headers`, so `List-Unsubscribe`
|
|
65
|
+
// is not known to reach the recipient.
|
|
66
|
+
}
|
|
67
|
+
readonly #apiKey: string
|
|
68
|
+
|
|
69
|
+
constructor(options: BrevoEmailSenderOptions) {
|
|
70
|
+
if (!isCredential(options.apiKey)) {
|
|
71
|
+
throw new EmailDeliveryError('Brevo API key is invalid', { code: 'invalid_configuration' })
|
|
72
|
+
}
|
|
73
|
+
if (options.from.name !== undefined && options.from.name.length > BREVO_MAX_NAME_LENGTH) {
|
|
74
|
+
throw new EmailDeliveryError(`Brevo sender name is longer than ${BREVO_MAX_NAME_LENGTH} characters`, { code: 'invalid_configuration' })
|
|
75
|
+
}
|
|
76
|
+
super({ label: 'Brevo', provider: 'brevo' }, options)
|
|
77
|
+
this.#apiKey = options.apiKey
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected async request(message: EmailMessage): Promise<HttpEmailRequest> {
|
|
81
|
+
const name = message.fromName ?? this.from.name
|
|
82
|
+
if (name !== undefined && name.length > BREVO_MAX_NAME_LENGTH) {
|
|
83
|
+
throw new EmailDeliveryError(`Brevo sends no sender name longer than ${BREVO_MAX_NAME_LENGTH} characters`, { code: 'invalid_message' })
|
|
84
|
+
}
|
|
85
|
+
const attachments = message.attachments ?? []
|
|
86
|
+
return {
|
|
87
|
+
url: BREVO_SEND_URL,
|
|
88
|
+
headers: { 'api-key': this.#apiKey, Accept: 'application/json' },
|
|
89
|
+
body: {
|
|
90
|
+
sender: { email: this.from.address, ...(name === undefined ? {} : { name }) },
|
|
91
|
+
to: [{ email: message.to }],
|
|
92
|
+
subject: message.subject,
|
|
93
|
+
// Brevo requires an HTML body without a template; a message without one, or with a blank one, gets its text
|
|
94
|
+
// as HTML, so the recipient never sees an empty message.
|
|
95
|
+
htmlContent: message.html === undefined || message.html.trim() === '' ? brevoHtmlOfText(message.text) : message.html,
|
|
96
|
+
textContent: message.text,
|
|
97
|
+
...(message.replyTo === undefined ? {} : { replyTo: { email: message.replyTo } }),
|
|
98
|
+
headers: { idempotencyKey: await brevoIdempotencyKey(message.idempotencyKey) },
|
|
99
|
+
...(attachments.length === 0
|
|
100
|
+
? {}
|
|
101
|
+
: { attachment: attachments.map((attachment) => ({ name: attachment.filename, content: base64Of(attachment.content) })) }),
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
protected messageId(response: ProviderResponse): string | undefined {
|
|
107
|
+
return brevoSuccessSchema.safeParse(response.body).data?.messageId
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected override refusal(response: ProviderResponse): EmailDeliveryError | undefined {
|
|
111
|
+
const status = response.status
|
|
112
|
+
const code = brevoErrorSchema.safeParse(response.body).data?.code
|
|
113
|
+
if (status === 402 || (code !== undefined && NO_CREDITS_CODES.has(code))) {
|
|
114
|
+
return new EmailDeliveryError(`Brevo account has no credits left (${status})`, { code: 'quota_exceeded', httpStatus: status })
|
|
115
|
+
}
|
|
116
|
+
// A 429 or a 5xx keeps the meaning of its status whatever its code.
|
|
117
|
+
if (code === undefined || status >= 500 || status === 429) return undefined
|
|
118
|
+
if (DUPLICATE_CODES.has(code)) {
|
|
119
|
+
// Brevo took a request under this key, or an identical one, and does not say whether its content matched.
|
|
120
|
+
return new EmailDeliveryError(`Brevo already took a request under this idempotency key (${status})`, {
|
|
121
|
+
code: 'idempotency_conflict',
|
|
122
|
+
httpStatus: status,
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
if (NOT_ALLOWED_CODES.has(code)) {
|
|
126
|
+
return new EmailDeliveryError(`Brevo refused the key or the account (${status})`, { code: 'provider_unauthorized', httpStatus: status })
|
|
127
|
+
}
|
|
128
|
+
return undefined
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The message's key as Brevo takes it, a UUID: the first 16 bytes of its SHA-256 with the version 4 and variant bits
|
|
134
|
+
* set. One key is always one UUID, so a retry sends the same one; Brevo recommends a version 4 UUID.
|
|
135
|
+
*/
|
|
136
|
+
async function brevoIdempotencyKey(key: string): Promise<string> {
|
|
137
|
+
const bytes = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(key))).slice(0, 16)
|
|
138
|
+
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40
|
|
139
|
+
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80
|
|
140
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')
|
|
141
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A plain text as the HTML body Brevo requires: every character escaped, each line break a `<br>`. */
|
|
145
|
+
export function brevoHtmlOfText(text: string): string {
|
|
146
|
+
const escaped = text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''')
|
|
147
|
+
return escaped.replace(/\r\n|\r|\n/g, '<br>\n')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const brevoVariablesSchema = z.object({ FABRIKA_EMAIL_BREVO_API_KEY: credentialVariable })
|
|
151
|
+
|
|
152
|
+
export const brevoEmailProvider: EmailProvider = {
|
|
153
|
+
variables: [{ name: 'FABRIKA_EMAIL_BREVO_API_KEY', secret: true, required: true }],
|
|
154
|
+
create({ from, env, fetch }) {
|
|
155
|
+
const variables = parseProviderVariables(brevoVariablesSchema, env)
|
|
156
|
+
return new BrevoEmailSender({ apiKey: variables.FABRIKA_EMAIL_BREVO_API_KEY, from, fetch })
|
|
157
|
+
},
|
|
158
|
+
}
|
package/src/conformance.ts
CHANGED
|
@@ -280,6 +280,20 @@ function describeHttpSender(harness: EmailSenderHttpHarness): void {
|
|
|
280
280
|
expect(current.requests).toHaveLength(0)
|
|
281
281
|
})
|
|
282
282
|
|
|
283
|
+
test('refuses an attachment of a file type outside the ones it says it sends, without a request', async () => {
|
|
284
|
+
const current = httpCase(async (request) => harness.answers.accepted(request))
|
|
285
|
+
const allowed = current.sender.capabilities.attachmentExtensions
|
|
286
|
+
if (allowed === undefined || current.sender.capabilities.maxAttachmentBytes === undefined) return
|
|
287
|
+
const extension = ['json', 'svg', 'webp', 'bin'].find((candidate) => !allowed.includes(candidate))
|
|
288
|
+
if (extension === undefined) throw new Error('every probe extension is allowed: pick another')
|
|
289
|
+
const message: EmailMessage = {
|
|
290
|
+
...ATTACHMENT_MESSAGE,
|
|
291
|
+
attachments: [{ filename: `report.${extension}`, contentType: 'application/octet-stream', content: ONE_BYTE }],
|
|
292
|
+
}
|
|
293
|
+
await expectRejection(() => current.sender.send(message, new AbortController().signal), 'invalid_message', () => MESSAGE_MARKERS)
|
|
294
|
+
expect(current.requests).toHaveLength(0)
|
|
295
|
+
})
|
|
296
|
+
|
|
283
297
|
test('refuses a body shorter than it says it sends, counted in characters once trimmed, without a request', async () => {
|
|
284
298
|
const current = httpCase(async (request) => harness.answers.accepted(request))
|
|
285
299
|
const min = current.sender.capabilities.minBodyLength
|
package/src/email.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface EmailSenderCapabilities {
|
|
|
55
55
|
readonly maxAttachmentBytes?: number
|
|
56
56
|
/** File extensions it refuses an attachment for, lowercase and without the dot; absent: none. */
|
|
57
57
|
readonly refusedAttachmentExtensions?: readonly string[]
|
|
58
|
+
/** The only file extensions it sends an attachment with, lowercase and without the dot; absent: any. */
|
|
59
|
+
readonly attachmentExtensions?: readonly string[]
|
|
58
60
|
/** The fewest characters a text or HTML body has once trimmed; absent: any body that is not blank. */
|
|
59
61
|
readonly minBodyLength?: number
|
|
60
62
|
/** Whether it sends a `broadcast` message, on its provider's channel for them where it has one; absent is no. */
|
package/src/providers.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ahaSendEmailProvider } from './ahasend.js'
|
|
2
|
+
import { brevoEmailProvider } from './brevo.js'
|
|
2
3
|
import { cloudflareEmailProvider } from './cloudflare.js'
|
|
3
4
|
import type { EmailProviderRegistry, EmailProviderVariable } from './config.js'
|
|
4
5
|
import { lettermintEmailProvider } from './lettermint.js'
|
|
@@ -12,6 +13,7 @@ import { smartEmailingEmailProvider } from './smartemailing.js'
|
|
|
12
13
|
*/
|
|
13
14
|
export const builtinEmailProviders = {
|
|
14
15
|
ahasend: ahaSendEmailProvider,
|
|
16
|
+
brevo: brevoEmailProvider,
|
|
15
17
|
cloudflare: cloudflareEmailProvider,
|
|
16
18
|
lettermint: lettermintEmailProvider,
|
|
17
19
|
postmark: postmarkEmailProvider,
|
|
@@ -32,6 +34,7 @@ export const builtinEmailProviderVariables: readonly EmailProviderVariable[] = O
|
|
|
32
34
|
*/
|
|
33
35
|
export const builtinEmailProviderSince = {
|
|
34
36
|
ahasend: '0.8.2',
|
|
37
|
+
brevo: '0.9.0-dev.17',
|
|
35
38
|
cloudflare: '0.9.0',
|
|
36
39
|
lettermint: '0.8.2',
|
|
37
40
|
postmark: '0.8.2',
|
package/src/validation.ts
CHANGED
|
@@ -75,8 +75,8 @@ export function validateEmailMessage(message: EmailMessage): void {
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Refuses a message whose attachments `capabilities` does not carry: any attachment where the transport sends none,
|
|
78
|
-
* more bytes together than its `maxAttachmentBytes`, or a file whose extension it refuses
|
|
79
|
-
* in the message.
|
|
78
|
+
* more bytes together than its `maxAttachmentBytes`, or a file whose extension it refuses or does not list in
|
|
79
|
+
* `attachmentExtensions`. `label` names the transport in the message.
|
|
80
80
|
*/
|
|
81
81
|
export function validateEmailAttachments(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void {
|
|
82
82
|
const attachments = message.attachments ?? []
|
|
@@ -86,9 +86,12 @@ export function validateEmailAttachments(message: EmailMessage, capabilities: Em
|
|
|
86
86
|
const bytes = attachmentBytes(message)
|
|
87
87
|
if (bytes > limit) throw invalidMessage(`Email attachments have ${bytes} bytes, more than the ${limit} ${label} sends`)
|
|
88
88
|
const refused = capabilities.refusedAttachmentExtensions ?? []
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const allowed = capabilities.attachmentExtensions
|
|
90
|
+
const refusedType = (filename: string): boolean => {
|
|
91
|
+
const extension = extensionOf(filename)
|
|
92
|
+
return refused.includes(extension) || (allowed !== undefined && !allowed.includes(extension))
|
|
91
93
|
}
|
|
94
|
+
if (attachments.some((attachment) => refusedType(attachment.filename))) throw invalidMessage(`${label} sends no attachment of this file type`)
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
/** Refuses a `broadcast` message where the transport sends none. */
|
|
@@ -107,7 +110,7 @@ export function validateEmailBodies(message: EmailMessage, capabilities: EmailSe
|
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
/** The extension after the last dot, lowercase; empty without one. */
|
|
110
|
-
function extensionOf(filename: string): string {
|
|
113
|
+
export function extensionOf(filename: string): string {
|
|
111
114
|
const dot = filename.lastIndexOf('.')
|
|
112
115
|
return dot < 0 ? '' : filename.slice(dot + 1).toLowerCase()
|
|
113
116
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EmailProvider } from './config.js';
|
|
2
|
+
import { EmailDeliveryError, type EmailMessage, type EmailSenderCapabilities } from './email.js';
|
|
3
|
+
import { type HttpEmailRequest, HttpEmailSender, type HttpEmailSenderOptions } from './http-sender.js';
|
|
4
|
+
import type { ProviderResponse } from './http.js';
|
|
5
|
+
export interface BrevoEmailSenderOptions extends HttpEmailSenderOptions {
|
|
6
|
+
/** An API key (v3) of the account. */
|
|
7
|
+
readonly apiKey: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class BrevoEmailSender extends HttpEmailSender {
|
|
10
|
+
#private;
|
|
11
|
+
readonly capabilities: EmailSenderCapabilities;
|
|
12
|
+
constructor(options: BrevoEmailSenderOptions);
|
|
13
|
+
protected request(message: EmailMessage): Promise<HttpEmailRequest>;
|
|
14
|
+
protected messageId(response: ProviderResponse): string | undefined;
|
|
15
|
+
protected refusal(response: ProviderResponse): EmailDeliveryError | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** A plain text as the HTML body Brevo requires: every character escaped, each line break a `<br>`. */
|
|
18
|
+
export declare function brevoHtmlOfText(text: string): string;
|
|
19
|
+
export declare const brevoEmailProvider: EmailProvider;
|
package/types/src/email.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export interface EmailSenderCapabilities {
|
|
|
51
51
|
readonly maxAttachmentBytes?: number;
|
|
52
52
|
/** File extensions it refuses an attachment for, lowercase and without the dot; absent: none. */
|
|
53
53
|
readonly refusedAttachmentExtensions?: readonly string[];
|
|
54
|
+
/** The only file extensions it sends an attachment with, lowercase and without the dot; absent: any. */
|
|
55
|
+
readonly attachmentExtensions?: readonly string[];
|
|
54
56
|
/** The fewest characters a text or HTML body has once trimmed; absent: any body that is not blank. */
|
|
55
57
|
readonly minBodyLength?: number;
|
|
56
58
|
/** Whether it sends a `broadcast` message, on its provider's channel for them where it has one; absent is no. */
|
package/types/src/providers.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { EmailProviderVariable } from './config.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const builtinEmailProviders: {
|
|
7
7
|
ahasend: import("./config.js").EmailProvider;
|
|
8
|
+
brevo: import("./config.js").EmailProvider;
|
|
8
9
|
cloudflare: import("./config.js").EmailProvider;
|
|
9
10
|
lettermint: import("./config.js").EmailProvider;
|
|
10
11
|
postmark: import("./config.js").EmailProvider;
|
|
@@ -21,6 +22,7 @@ export declare const builtinEmailProviderVariables: readonly EmailProviderVariab
|
|
|
21
22
|
*/
|
|
22
23
|
export declare const builtinEmailProviderSince: {
|
|
23
24
|
readonly ahasend: "0.8.2";
|
|
25
|
+
readonly brevo: "0.9.0-dev.17";
|
|
24
26
|
readonly cloudflare: "0.9.0";
|
|
25
27
|
readonly lettermint: "0.8.2";
|
|
26
28
|
readonly postmark: "0.8.2";
|
|
@@ -16,14 +16,16 @@ export declare function isValidEmailSenderIdentity(identity: EmailSenderIdentity
|
|
|
16
16
|
export declare function validateEmailMessage(message: EmailMessage): void;
|
|
17
17
|
/**
|
|
18
18
|
* Refuses a message whose attachments `capabilities` does not carry: any attachment where the transport sends none,
|
|
19
|
-
* more bytes together than its `maxAttachmentBytes`, or a file whose extension it refuses
|
|
20
|
-
* in the message.
|
|
19
|
+
* more bytes together than its `maxAttachmentBytes`, or a file whose extension it refuses or does not list in
|
|
20
|
+
* `attachmentExtensions`. `label` names the transport in the message.
|
|
21
21
|
*/
|
|
22
22
|
export declare function validateEmailAttachments(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
23
23
|
/** Refuses a `broadcast` message where the transport sends none. */
|
|
24
24
|
export declare function validateEmailBroadcast(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
25
25
|
/** Refuses a text or HTML body shorter than the transport's `minBodyLength`, counted in characters once trimmed. */
|
|
26
26
|
export declare function validateEmailBodies(message: EmailMessage, capabilities: EmailSenderCapabilities, label: string): void;
|
|
27
|
+
/** The extension after the last dot, lowercase; empty without one. */
|
|
28
|
+
export declare function extensionOf(filename: string): string;
|
|
27
29
|
/** The most files one message carries. */
|
|
28
30
|
export declare const MAX_EMAIL_ATTACHMENTS = 20;
|
|
29
31
|
/** 1..255 characters, no control characters, no path separator and no `"`, so every transport can quote it. */
|