edge-mailer 0.6.0 → 0.6.1
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/CHANGELOG.md +5 -0
- package/CLIENT-INTEGRATION.md +5 -2
- package/README.md +7 -7
- package/dist/cloudflare.d.mts +1 -1
- package/dist/cloudflare.d.ts +1 -1
- package/dist/deno.d.mts +9 -2
- package/dist/deno.d.ts +9 -2
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/{pool-CcxclJQJ.d.mts → pool-Db8Z1fqb.d.mts} +69 -0
- package/dist/{pool-CcxclJQJ.d.ts → pool-Db8Z1fqb.d.ts} +69 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/CLIENT-INTEGRATION.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Client Integration
|
|
2
2
|
|
|
3
3
|
Edge Mailer exposes one SMTP client API with runtime-specific entrypoints.
|
|
4
|
-
Cloudflare Workers and Deno are both first-class edge runtimes.
|
|
5
|
-
Workers was implemented first; it is not a priority tier over Deno.
|
|
4
|
+
Cloudflare Workers and Deno are both first-class edge runtimes.
|
|
6
5
|
|
|
7
6
|
## Runtime Imports
|
|
8
7
|
|
|
@@ -24,6 +23,10 @@ The default package entrypoint remains Cloudflare-compatible:
|
|
|
24
23
|
import { EdgeMailer } from 'edge-mailer'
|
|
25
24
|
```
|
|
26
25
|
|
|
26
|
+
The default npm entrypoint imports `cloudflare:sockets`, so it is not intended
|
|
27
|
+
to load directly in plain Node.js. Use a runtime-specific subpath for non-
|
|
28
|
+
Cloudflare environments.
|
|
29
|
+
|
|
27
30
|
## Minimal Send
|
|
28
31
|
|
|
29
32
|
```ts
|
package/README.md
CHANGED
|
@@ -4,9 +4,7 @@ Edge Mailer is a serverless SMTP submission toolkit for applications that need
|
|
|
4
4
|
to send through existing SMTP infrastructure from modern edge runtimes.
|
|
5
5
|
|
|
6
6
|
The current implementation supports Cloudflare Workers and Deno as first-class
|
|
7
|
-
edge runtimes.
|
|
8
|
-
not a priority tier over Deno. The public API is versioned as a `0.x`
|
|
9
|
-
prerelease surface.
|
|
7
|
+
edge runtimes. The public API is versioned as a `0.x` prerelease surface.
|
|
10
8
|
|
|
11
9
|
Install from npm for Cloudflare Workers and Node-compatible build pipelines:
|
|
12
10
|
|
|
@@ -62,6 +60,9 @@ Use the default import or Cloudflare subpath for Cloudflare Workers:
|
|
|
62
60
|
import { EdgeMailer } from 'edge-mailer/cloudflare'
|
|
63
61
|
```
|
|
64
62
|
|
|
63
|
+
The default npm entrypoint is Cloudflare-compatible and imports
|
|
64
|
+
`cloudflare:sockets`; it is not intended to load directly in plain Node.js.
|
|
65
|
+
|
|
65
66
|
Use the Deno subpath for Deno:
|
|
66
67
|
|
|
67
68
|
```ts
|
|
@@ -94,10 +95,9 @@ Runnable samples and deploy quickstarts live in [sample](sample):
|
|
|
94
95
|
|
|
95
96
|
## Roadmap
|
|
96
97
|
|
|
97
|
-
Cloudflare Workers and Deno are both first-class edge runtimes.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
grouped by product risk:
|
|
98
|
+
Cloudflare Workers and Deno are both first-class edge runtimes. Future work
|
|
99
|
+
should keep both runtimes aligned unless a runtime-specific platform limit is
|
|
100
|
+
documented. The next useful work is grouped by product risk:
|
|
101
101
|
|
|
102
102
|
- Stabilization: publish a v0 package surface, keep runtime subpaths stable,
|
|
103
103
|
expand live smokes across at least two SMTP providers, and keep package
|
package/dist/cloudflare.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, B as BatchSendOptions, c as BatchSendResult, C as Credentials, D as DkimConfig, d as DsnOptions, E as EdgeMailerOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, i as EmailOptions, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, n as SmtpConnectionPool, o as SmtpMailer, p as SmtpPoolOptions, q as SmtpRejectedRecipient, r as SmtpSendReceipt, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, B as BatchSendOptions, c as BatchSendResult, C as Credentials, D as DkimConfig, d as DsnOptions, E as EdgeMailerOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, i as EmailOptions, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, n as SmtpConnectionPool, o as SmtpMailer, p as SmtpPoolOptions, q as SmtpRejectedRecipient, r as SmtpSendReceipt, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.mjs';
|
|
2
2
|
export { EdgeMailer, cloudflareSocketConnector } from './index.mjs';
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, B as BatchSendOptions, c as BatchSendResult, C as Credentials, D as DkimConfig, d as DsnOptions, E as EdgeMailerOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, i as EmailOptions, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, n as SmtpConnectionPool, o as SmtpMailer, p as SmtpPoolOptions, q as SmtpRejectedRecipient, r as SmtpSendReceipt, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, B as BatchSendOptions, c as BatchSendResult, C as Credentials, D as DkimConfig, d as DsnOptions, E as EdgeMailerOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, i as EmailOptions, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, n as SmtpConnectionPool, o as SmtpMailer, p as SmtpPoolOptions, q as SmtpRejectedRecipient, r as SmtpSendReceipt, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.js';
|
|
2
2
|
export { EdgeMailer, cloudflareSocketConnector } from './index.js';
|
package/dist/deno.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-
|
|
2
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-Db8Z1fqb.mjs';
|
|
2
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.mjs';
|
|
3
3
|
|
|
4
4
|
type DenoConn = {
|
|
5
5
|
readable: ReadableStream<Uint8Array>;
|
|
@@ -7,6 +7,7 @@ type DenoConn = {
|
|
|
7
7
|
closed?: Promise<void>;
|
|
8
8
|
close(): void;
|
|
9
9
|
};
|
|
10
|
+
/** Subset of Deno socket APIs required by the Deno connector. */
|
|
10
11
|
type DenoSocketRuntime = {
|
|
11
12
|
connect(options: {
|
|
12
13
|
hostname: string;
|
|
@@ -22,12 +23,18 @@ type DenoSocketRuntime = {
|
|
|
22
23
|
hostname?: string;
|
|
23
24
|
}): Promise<DenoConn>;
|
|
24
25
|
};
|
|
26
|
+
/** Creates an SMTP socket connector for Deno runtimes. */
|
|
25
27
|
declare function createDenoSocketConnector(deno?: DenoSocketRuntime): EdgeSocketConnector;
|
|
28
|
+
/** Deno mailer using Deno TCP, TLS, and STARTTLS socket APIs. */
|
|
26
29
|
declare class DenoMailer extends SmtpMailer {
|
|
27
30
|
private constructor();
|
|
31
|
+
/** Opens and initializes an SMTP session in Deno. */
|
|
28
32
|
static connect(options: EdgeMailerOptions): Promise<DenoMailer>;
|
|
33
|
+
/** Sends one message and closes the SMTP session afterward. */
|
|
29
34
|
static send(options: EdgeMailerOptions, email: EmailOptions): Promise<SmtpSendReceipt>;
|
|
35
|
+
/** Sends messages sequentially over one SMTP session. */
|
|
30
36
|
static sendBatch(options: EdgeMailerOptions, emails: EmailOptions[], batchOptions?: BatchSendOptions): Promise<BatchSendResult>;
|
|
37
|
+
/** Creates a bounded pool of Deno SMTP sessions. */
|
|
31
38
|
static createPool(options: EdgeMailerOptions): SmtpConnectionPool<DenoMailer>;
|
|
32
39
|
}
|
|
33
40
|
|
package/dist/deno.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-
|
|
2
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-Db8Z1fqb.js';
|
|
2
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.js';
|
|
3
3
|
|
|
4
4
|
type DenoConn = {
|
|
5
5
|
readable: ReadableStream<Uint8Array>;
|
|
@@ -7,6 +7,7 @@ type DenoConn = {
|
|
|
7
7
|
closed?: Promise<void>;
|
|
8
8
|
close(): void;
|
|
9
9
|
};
|
|
10
|
+
/** Subset of Deno socket APIs required by the Deno connector. */
|
|
10
11
|
type DenoSocketRuntime = {
|
|
11
12
|
connect(options: {
|
|
12
13
|
hostname: string;
|
|
@@ -22,12 +23,18 @@ type DenoSocketRuntime = {
|
|
|
22
23
|
hostname?: string;
|
|
23
24
|
}): Promise<DenoConn>;
|
|
24
25
|
};
|
|
26
|
+
/** Creates an SMTP socket connector for Deno runtimes. */
|
|
25
27
|
declare function createDenoSocketConnector(deno?: DenoSocketRuntime): EdgeSocketConnector;
|
|
28
|
+
/** Deno mailer using Deno TCP, TLS, and STARTTLS socket APIs. */
|
|
26
29
|
declare class DenoMailer extends SmtpMailer {
|
|
27
30
|
private constructor();
|
|
31
|
+
/** Opens and initializes an SMTP session in Deno. */
|
|
28
32
|
static connect(options: EdgeMailerOptions): Promise<DenoMailer>;
|
|
33
|
+
/** Sends one message and closes the SMTP session afterward. */
|
|
29
34
|
static send(options: EdgeMailerOptions, email: EmailOptions): Promise<SmtpSendReceipt>;
|
|
35
|
+
/** Sends messages sequentially over one SMTP session. */
|
|
30
36
|
static sendBatch(options: EdgeMailerOptions, emails: EmailOptions[], batchOptions?: BatchSendOptions): Promise<BatchSendResult>;
|
|
37
|
+
/** Creates a bounded pool of Deno SMTP sessions. */
|
|
31
38
|
static createPool(options: EdgeMailerOptions): SmtpConnectionPool<DenoMailer>;
|
|
32
39
|
}
|
|
33
40
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-
|
|
2
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-Db8Z1fqb.mjs';
|
|
2
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.mjs';
|
|
3
3
|
|
|
4
|
+
/** Cloudflare Workers socket connector backed by `cloudflare:sockets`. */
|
|
4
5
|
declare const cloudflareSocketConnector: EdgeSocketConnector;
|
|
6
|
+
/** Cloudflare Workers mailer using outbound TCP sockets. */
|
|
5
7
|
declare class EdgeMailer extends SmtpMailer {
|
|
6
8
|
private constructor();
|
|
9
|
+
/** Opens and initializes an SMTP session in a Cloudflare Worker. */
|
|
7
10
|
static connect(options: EdgeMailerOptions): Promise<EdgeMailer>;
|
|
11
|
+
/** Sends one message and closes the SMTP session afterward. */
|
|
8
12
|
static send(options: EdgeMailerOptions, email: EmailOptions): Promise<SmtpSendReceipt>;
|
|
13
|
+
/** Sends messages sequentially over one SMTP session. */
|
|
9
14
|
static sendBatch(options: EdgeMailerOptions, emails: EmailOptions[], batchOptions?: BatchSendOptions): Promise<BatchSendResult>;
|
|
15
|
+
/** Creates a bounded pool of Cloudflare SMTP sessions. */
|
|
10
16
|
static createPool(options: EdgeMailerOptions): SmtpConnectionPool<EdgeMailer>;
|
|
11
17
|
}
|
|
12
18
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-
|
|
2
|
-
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-
|
|
1
|
+
import { o as SmtpMailer, E as EdgeMailerOptions, i as EmailOptions, r as SmtpSendReceipt, B as BatchSendOptions, c as BatchSendResult, n as SmtpConnectionPool, e as EdgeSocketConnector } from './pool-Db8Z1fqb.js';
|
|
2
|
+
export { A as AttachmentDisposition, a as AttachmentEncoding, b as AuthType, C as Credentials, D as DkimConfig, d as DsnOptions, f as Email, g as EmailAttachment, h as EmailAttachmentContent, L as LogLevel, M as MailBodyType, j as MailEnvelopeOptions, P as PipeliningMode, S as SMTPError, k as SMTPErrorOptions, l as SMTPStage, m as SmtpBodyType, p as SmtpPoolOptions, q as SmtpRejectedRecipient, U as User, s as encodeHeader, t as signDkimMessage, v as validateDkimConfig } from './pool-Db8Z1fqb.js';
|
|
3
3
|
|
|
4
|
+
/** Cloudflare Workers socket connector backed by `cloudflare:sockets`. */
|
|
4
5
|
declare const cloudflareSocketConnector: EdgeSocketConnector;
|
|
6
|
+
/** Cloudflare Workers mailer using outbound TCP sockets. */
|
|
5
7
|
declare class EdgeMailer extends SmtpMailer {
|
|
6
8
|
private constructor();
|
|
9
|
+
/** Opens and initializes an SMTP session in a Cloudflare Worker. */
|
|
7
10
|
static connect(options: EdgeMailerOptions): Promise<EdgeMailer>;
|
|
11
|
+
/** Sends one message and closes the SMTP session afterward. */
|
|
8
12
|
static send(options: EdgeMailerOptions, email: EmailOptions): Promise<SmtpSendReceipt>;
|
|
13
|
+
/** Sends messages sequentially over one SMTP session. */
|
|
9
14
|
static sendBatch(options: EdgeMailerOptions, emails: EmailOptions[], batchOptions?: BatchSendOptions): Promise<BatchSendResult>;
|
|
15
|
+
/** Creates a bounded pool of Cloudflare SMTP sessions. */
|
|
10
16
|
static createPool(options: EdgeMailerOptions): SmtpConnectionPool<EdgeMailer>;
|
|
11
17
|
}
|
|
12
18
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/** Encodes non-ASCII header text using RFC 2047 quoted-printable words. */
|
|
1
2
|
declare function encodeHeader(text: string): string;
|
|
3
|
+
/** Email address with an optional display name. */
|
|
2
4
|
type User = {
|
|
3
5
|
name?: string;
|
|
4
6
|
email: string;
|
|
5
7
|
};
|
|
8
|
+
/** SMTP delivery status notification options. */
|
|
6
9
|
type DsnOptions = {
|
|
7
10
|
envelopeId?: string;
|
|
8
11
|
RET?: {
|
|
@@ -17,7 +20,9 @@ type DsnOptions = {
|
|
|
17
20
|
};
|
|
18
21
|
ORCPT?: string;
|
|
19
22
|
};
|
|
23
|
+
/** SMTP MAIL FROM BODY parameter value. */
|
|
20
24
|
type MailBodyType = '7BIT' | '8BITMIME';
|
|
25
|
+
/** SMTP envelope overrides used for MAIL FROM and RCPT TO commands. */
|
|
21
26
|
type MailEnvelopeOptions = {
|
|
22
27
|
from?: string;
|
|
23
28
|
to?: string | string[];
|
|
@@ -26,9 +31,13 @@ type MailEnvelopeOptions = {
|
|
|
26
31
|
smtpUtf8?: boolean;
|
|
27
32
|
requireTls?: boolean;
|
|
28
33
|
};
|
|
34
|
+
/** MIME content-transfer-encoding for an attachment body. */
|
|
29
35
|
type AttachmentEncoding = 'base64' | 'quoted-printable' | '7bit';
|
|
36
|
+
/** MIME content disposition for attachment parts. */
|
|
30
37
|
type AttachmentDisposition = 'attachment' | 'inline';
|
|
38
|
+
/** Supported attachment content inputs. */
|
|
31
39
|
type EmailAttachmentContent = string | Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
|
|
40
|
+
/** File or inline part to include in the generated MIME message. */
|
|
32
41
|
type EmailAttachment = {
|
|
33
42
|
filename: string;
|
|
34
43
|
content: EmailAttachmentContent;
|
|
@@ -38,6 +47,7 @@ type EmailAttachment = {
|
|
|
38
47
|
contentId?: string;
|
|
39
48
|
disposition?: AttachmentDisposition;
|
|
40
49
|
};
|
|
50
|
+
/** High-level email message options accepted by mailer send methods. */
|
|
41
51
|
type EmailOptions = {
|
|
42
52
|
from: string | User;
|
|
43
53
|
to: string | string[] | User | User[];
|
|
@@ -52,28 +62,47 @@ type EmailOptions = {
|
|
|
52
62
|
envelope?: MailEnvelopeOptions;
|
|
53
63
|
dsnOverride?: DsnOptions;
|
|
54
64
|
};
|
|
65
|
+
/** Builds MIME email messages and SMTP DATA payloads from {@link EmailOptions}. */
|
|
55
66
|
declare class Email {
|
|
67
|
+
/** Sender address used for MIME From and default envelope sender. */
|
|
56
68
|
readonly from: User;
|
|
69
|
+
/** Primary recipients emitted in the MIME To header. */
|
|
57
70
|
readonly to: User[];
|
|
71
|
+
/** Reply-To address. */
|
|
58
72
|
readonly reply?: User;
|
|
73
|
+
/** Carbon-copy recipients emitted in the MIME Cc header. */
|
|
59
74
|
readonly cc?: User[];
|
|
75
|
+
/** Blind-copy recipients used for envelope delivery only. */
|
|
60
76
|
readonly bcc?: User[];
|
|
77
|
+
/** MIME Subject header value. */
|
|
61
78
|
readonly subject: string;
|
|
79
|
+
/** Plain text body. */
|
|
62
80
|
readonly text?: string;
|
|
81
|
+
/** HTML body. */
|
|
63
82
|
readonly html?: string;
|
|
83
|
+
/** SMTP envelope overrides. */
|
|
64
84
|
readonly envelope?: Omit<MailEnvelopeOptions, 'to'> & {
|
|
65
85
|
to?: string[];
|
|
66
86
|
};
|
|
87
|
+
/** Per-message DSN overrides. */
|
|
67
88
|
readonly dsnOverride?: DsnOptions;
|
|
89
|
+
/** Attachments and inline content parts. */
|
|
68
90
|
readonly attachments?: EmailAttachment[];
|
|
91
|
+
/** Custom MIME headers. */
|
|
69
92
|
readonly headers: Record<string, string>;
|
|
93
|
+
/** Marks this email as sent for callers tracking queued send state. */
|
|
70
94
|
setSent: () => void;
|
|
95
|
+
/** Marks this email as failed for callers tracking queued send state. */
|
|
71
96
|
setSentError: (e: unknown) => void;
|
|
97
|
+
/** Resolves when the email has been sent by a mailer. */
|
|
72
98
|
sent: Promise<void>;
|
|
99
|
+
/** Creates a MIME message builder from high-level email options. */
|
|
73
100
|
constructor(options: EmailOptions);
|
|
74
101
|
private static toUsers;
|
|
75
102
|
private static toEnvelopeRecipients;
|
|
103
|
+
/** Returns MIME message data without SMTP dot-stuffing. */
|
|
76
104
|
getMessageData(): string;
|
|
105
|
+
/** Returns MIME message data, resolving Blob attachment content first. */
|
|
77
106
|
getMessageDataAsync(): Promise<string>;
|
|
78
107
|
private buildMessageData;
|
|
79
108
|
private resolveAttachments;
|
|
@@ -87,8 +116,11 @@ declare class Email {
|
|
|
87
116
|
private bytesToWrappedBase64;
|
|
88
117
|
private bytesToBase64;
|
|
89
118
|
private wrapBase64;
|
|
119
|
+
/** Returns SMTP DATA payload with dot-stuffing and final terminator. */
|
|
90
120
|
getEmailData(): string;
|
|
121
|
+
/** Returns SMTP DATA payload after resolving async attachment content. */
|
|
91
122
|
getEmailDataAsync(): Promise<string>;
|
|
123
|
+
/** Dot-stuffs MIME data and appends the SMTP DATA terminator. */
|
|
92
124
|
static toSmtpData(data: string): string;
|
|
93
125
|
private static applyDotStuffing;
|
|
94
126
|
private generateSafeBoundary;
|
|
@@ -101,15 +133,19 @@ declare class Email {
|
|
|
101
133
|
private resolveCC;
|
|
102
134
|
}
|
|
103
135
|
|
|
136
|
+
/** DKIM signing options for RSA-SHA256 signatures. */
|
|
104
137
|
type DkimConfig = {
|
|
105
138
|
domainName: string;
|
|
106
139
|
keySelector: string;
|
|
107
140
|
privateKey: string;
|
|
108
141
|
headerFieldNames?: string[];
|
|
109
142
|
};
|
|
143
|
+
/** Validates DKIM configuration before message signing. */
|
|
110
144
|
declare function validateDkimConfig(dkim: DkimConfig | undefined): void;
|
|
145
|
+
/** Returns a MIME message prefixed with a DKIM-Signature header. */
|
|
111
146
|
declare function signDkimMessage(message: string, dkim: DkimConfig): Promise<string>;
|
|
112
147
|
|
|
148
|
+
/** Verbosity levels for SMTP client logging. */
|
|
113
149
|
declare enum LogLevel {
|
|
114
150
|
DEBUG = 0,
|
|
115
151
|
INFO = 1,
|
|
@@ -118,7 +154,9 @@ declare enum LogLevel {
|
|
|
118
154
|
NONE = 4
|
|
119
155
|
}
|
|
120
156
|
|
|
157
|
+
/** TLS mode requested from a runtime socket adapter. */
|
|
121
158
|
type SocketTlsMode = 'off' | 'on' | 'starttls';
|
|
159
|
+
/** Minimal readable/writable socket contract used by the SMTP core. */
|
|
122
160
|
type EdgeSocket = {
|
|
123
161
|
readable: ReadableStream<Uint8Array>;
|
|
124
162
|
writable: WritableStream<Uint8Array>;
|
|
@@ -127,24 +165,30 @@ type EdgeSocket = {
|
|
|
127
165
|
close(reason?: unknown): Promise<void> | void;
|
|
128
166
|
startTls?(): EdgeSocket | Promise<EdgeSocket>;
|
|
129
167
|
};
|
|
168
|
+
/** Runtime socket connection request. */
|
|
130
169
|
type EdgeSocketConnectOptions = {
|
|
131
170
|
hostname: string;
|
|
132
171
|
port: number;
|
|
133
172
|
tls: SocketTlsMode;
|
|
134
173
|
signal?: AbortSignal;
|
|
135
174
|
};
|
|
175
|
+
/** Runtime adapter that opens SMTP TCP/TLS sockets. */
|
|
136
176
|
type EdgeSocketConnector = {
|
|
137
177
|
connect(options: EdgeSocketConnectOptions): EdgeSocket | Promise<EdgeSocket>;
|
|
138
178
|
};
|
|
139
179
|
|
|
180
|
+
/** SMTP authentication mechanisms supported by the shared SMTP client. */
|
|
140
181
|
type AuthType = 'plain' | 'login' | 'cram-md5';
|
|
182
|
+
/** Username and password used for SMTP AUTH. */
|
|
141
183
|
type Credentials = {
|
|
142
184
|
username: string;
|
|
143
185
|
password: string;
|
|
144
186
|
};
|
|
187
|
+
/** Controls ordered batch behavior when one message fails. */
|
|
145
188
|
type BatchSendOptions = {
|
|
146
189
|
continueOnError?: boolean;
|
|
147
190
|
};
|
|
191
|
+
/** Recipient rejected by the SMTP server during the envelope phase. */
|
|
148
192
|
type SmtpRejectedRecipient = {
|
|
149
193
|
recipient: string;
|
|
150
194
|
response: string;
|
|
@@ -152,6 +196,7 @@ type SmtpRejectedRecipient = {
|
|
|
152
196
|
enhancedStatusCode?: string;
|
|
153
197
|
transient: boolean;
|
|
154
198
|
};
|
|
199
|
+
/** Structured receipt returned after an SMTP DATA transaction completes. */
|
|
155
200
|
type SmtpSendReceipt = {
|
|
156
201
|
messageId: string;
|
|
157
202
|
envelope: {
|
|
@@ -165,26 +210,40 @@ type SmtpSendReceipt = {
|
|
|
165
210
|
enhancedStatusCode?: string;
|
|
166
211
|
size: number;
|
|
167
212
|
};
|
|
213
|
+
/** Ordered result list returned by `sendBatch()` and `sendMany()`. */
|
|
168
214
|
type BatchSendResult = PromiseSettledResult<SmtpSendReceipt>[];
|
|
215
|
+
/** SMTP PIPELINING behavior. */
|
|
169
216
|
type PipeliningMode = 'auto' | false;
|
|
217
|
+
/** SMTP message body encoding advertised in MAIL FROM. */
|
|
170
218
|
type SmtpBodyType = '7BIT' | '8BITMIME';
|
|
219
|
+
/** Protocol stage attached to structured SMTP errors. */
|
|
171
220
|
type SMTPStage = 'connect' | 'greet' | 'ehlo' | 'helo' | 'starttls' | 'auth' | 'mail' | 'rcpt' | 'data' | 'body' | 'rset' | 'quit' | 'send' | 'read';
|
|
221
|
+
/** Constructor details for {@link SMTPError}. */
|
|
172
222
|
type SMTPErrorOptions = {
|
|
173
223
|
stage: SMTPStage;
|
|
174
224
|
command?: string;
|
|
175
225
|
response?: string;
|
|
176
226
|
cause?: unknown;
|
|
177
227
|
};
|
|
228
|
+
/** Error thrown when an SMTP command or socket stage fails. */
|
|
178
229
|
declare class SMTPError extends Error {
|
|
230
|
+
/** SMTP stage where the failure happened. */
|
|
179
231
|
readonly stage: SMTPStage;
|
|
232
|
+
/** SMTP command active when the failure happened, when available. */
|
|
180
233
|
readonly command?: string;
|
|
234
|
+
/** Raw SMTP response line associated with the failure. */
|
|
181
235
|
readonly response?: string;
|
|
236
|
+
/** Three-digit SMTP response code parsed from {@link response}. */
|
|
182
237
|
readonly responseCode?: number;
|
|
238
|
+
/** Enhanced status code parsed from {@link response}. */
|
|
183
239
|
readonly enhancedStatusCode?: string;
|
|
240
|
+
/** Whether the response code is a transient 4xx failure. */
|
|
184
241
|
readonly transient: boolean;
|
|
185
242
|
readonly cause?: unknown;
|
|
243
|
+
/** Creates a structured SMTP error. */
|
|
186
244
|
constructor(message: string, options: SMTPErrorOptions);
|
|
187
245
|
}
|
|
246
|
+
/** SMTP client configuration shared by Cloudflare and Deno runtimes. */
|
|
188
247
|
type EdgeMailerOptions = {
|
|
189
248
|
host: string;
|
|
190
249
|
port: number;
|
|
@@ -200,11 +259,13 @@ type EdgeMailerOptions = {
|
|
|
200
259
|
socketTimeoutMs?: number;
|
|
201
260
|
responseTimeoutMs?: number;
|
|
202
261
|
};
|
|
262
|
+
/** Connection-pool limits for repeated SMTP sends. */
|
|
203
263
|
type SmtpPoolOptions = {
|
|
204
264
|
maxConnections?: number;
|
|
205
265
|
maxMessagesPerConnection?: number;
|
|
206
266
|
idleTimeoutMs?: number;
|
|
207
267
|
};
|
|
268
|
+
/** Runtime-neutral SMTP session implementation used by runtime mailers. */
|
|
208
269
|
declare class SmtpMailer {
|
|
209
270
|
private readonly connector;
|
|
210
271
|
private readonly host;
|
|
@@ -240,9 +301,13 @@ declare class SmtpMailer {
|
|
|
240
301
|
private supportsStartTls;
|
|
241
302
|
private supportsPipelining;
|
|
242
303
|
protected constructor(options: EdgeMailerOptions, connector: EdgeSocketConnector, runtimeName?: string);
|
|
304
|
+
/** Sends one message over the active SMTP session. */
|
|
243
305
|
send(options: EmailOptions): Promise<SmtpSendReceipt>;
|
|
306
|
+
/** Sends messages sequentially over the active SMTP session. */
|
|
244
307
|
sendMany(emails: EmailOptions[], options?: BatchSendOptions): Promise<BatchSendResult>;
|
|
308
|
+
/** Closes the SMTP socket and rejects any queued sends. */
|
|
245
309
|
close(error?: Error): Promise<void>;
|
|
310
|
+
/** Returns whether the SMTP session is open and usable. */
|
|
246
311
|
isActive(): boolean;
|
|
247
312
|
protected initializeSmtpSession(): Promise<void>;
|
|
248
313
|
private sendEmail;
|
|
@@ -291,6 +356,7 @@ declare class SmtpMailer {
|
|
|
291
356
|
private getSocket;
|
|
292
357
|
}
|
|
293
358
|
|
|
359
|
+
/** Bounded SMTP connection pool for reusing runtime mailer sessions. */
|
|
294
360
|
declare class SmtpConnectionPool<TMailer extends SmtpMailer> {
|
|
295
361
|
private readonly options;
|
|
296
362
|
private readonly connectMailer;
|
|
@@ -305,8 +371,11 @@ declare class SmtpConnectionPool<TMailer extends SmtpMailer> {
|
|
|
305
371
|
private totalConnections;
|
|
306
372
|
private closed;
|
|
307
373
|
constructor(options: EdgeMailerOptions, connectMailer: (options: EdgeMailerOptions) => Promise<TMailer>);
|
|
374
|
+
/** Sends one message through an acquired SMTP session. */
|
|
308
375
|
send(email: Parameters<TMailer['send']>[0]): Promise<SmtpSendReceipt>;
|
|
376
|
+
/** Sends messages sequentially through the pool. */
|
|
309
377
|
sendMany(emails: Parameters<TMailer['send']>[0][], options?: BatchSendOptions): Promise<BatchSendResult>;
|
|
378
|
+
/** Closes all pooled SMTP sessions and rejects queued sends. */
|
|
310
379
|
close(): Promise<void>;
|
|
311
380
|
private acquire;
|
|
312
381
|
private release;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/** Encodes non-ASCII header text using RFC 2047 quoted-printable words. */
|
|
1
2
|
declare function encodeHeader(text: string): string;
|
|
3
|
+
/** Email address with an optional display name. */
|
|
2
4
|
type User = {
|
|
3
5
|
name?: string;
|
|
4
6
|
email: string;
|
|
5
7
|
};
|
|
8
|
+
/** SMTP delivery status notification options. */
|
|
6
9
|
type DsnOptions = {
|
|
7
10
|
envelopeId?: string;
|
|
8
11
|
RET?: {
|
|
@@ -17,7 +20,9 @@ type DsnOptions = {
|
|
|
17
20
|
};
|
|
18
21
|
ORCPT?: string;
|
|
19
22
|
};
|
|
23
|
+
/** SMTP MAIL FROM BODY parameter value. */
|
|
20
24
|
type MailBodyType = '7BIT' | '8BITMIME';
|
|
25
|
+
/** SMTP envelope overrides used for MAIL FROM and RCPT TO commands. */
|
|
21
26
|
type MailEnvelopeOptions = {
|
|
22
27
|
from?: string;
|
|
23
28
|
to?: string | string[];
|
|
@@ -26,9 +31,13 @@ type MailEnvelopeOptions = {
|
|
|
26
31
|
smtpUtf8?: boolean;
|
|
27
32
|
requireTls?: boolean;
|
|
28
33
|
};
|
|
34
|
+
/** MIME content-transfer-encoding for an attachment body. */
|
|
29
35
|
type AttachmentEncoding = 'base64' | 'quoted-printable' | '7bit';
|
|
36
|
+
/** MIME content disposition for attachment parts. */
|
|
30
37
|
type AttachmentDisposition = 'attachment' | 'inline';
|
|
38
|
+
/** Supported attachment content inputs. */
|
|
31
39
|
type EmailAttachmentContent = string | Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
|
|
40
|
+
/** File or inline part to include in the generated MIME message. */
|
|
32
41
|
type EmailAttachment = {
|
|
33
42
|
filename: string;
|
|
34
43
|
content: EmailAttachmentContent;
|
|
@@ -38,6 +47,7 @@ type EmailAttachment = {
|
|
|
38
47
|
contentId?: string;
|
|
39
48
|
disposition?: AttachmentDisposition;
|
|
40
49
|
};
|
|
50
|
+
/** High-level email message options accepted by mailer send methods. */
|
|
41
51
|
type EmailOptions = {
|
|
42
52
|
from: string | User;
|
|
43
53
|
to: string | string[] | User | User[];
|
|
@@ -52,28 +62,47 @@ type EmailOptions = {
|
|
|
52
62
|
envelope?: MailEnvelopeOptions;
|
|
53
63
|
dsnOverride?: DsnOptions;
|
|
54
64
|
};
|
|
65
|
+
/** Builds MIME email messages and SMTP DATA payloads from {@link EmailOptions}. */
|
|
55
66
|
declare class Email {
|
|
67
|
+
/** Sender address used for MIME From and default envelope sender. */
|
|
56
68
|
readonly from: User;
|
|
69
|
+
/** Primary recipients emitted in the MIME To header. */
|
|
57
70
|
readonly to: User[];
|
|
71
|
+
/** Reply-To address. */
|
|
58
72
|
readonly reply?: User;
|
|
73
|
+
/** Carbon-copy recipients emitted in the MIME Cc header. */
|
|
59
74
|
readonly cc?: User[];
|
|
75
|
+
/** Blind-copy recipients used for envelope delivery only. */
|
|
60
76
|
readonly bcc?: User[];
|
|
77
|
+
/** MIME Subject header value. */
|
|
61
78
|
readonly subject: string;
|
|
79
|
+
/** Plain text body. */
|
|
62
80
|
readonly text?: string;
|
|
81
|
+
/** HTML body. */
|
|
63
82
|
readonly html?: string;
|
|
83
|
+
/** SMTP envelope overrides. */
|
|
64
84
|
readonly envelope?: Omit<MailEnvelopeOptions, 'to'> & {
|
|
65
85
|
to?: string[];
|
|
66
86
|
};
|
|
87
|
+
/** Per-message DSN overrides. */
|
|
67
88
|
readonly dsnOverride?: DsnOptions;
|
|
89
|
+
/** Attachments and inline content parts. */
|
|
68
90
|
readonly attachments?: EmailAttachment[];
|
|
91
|
+
/** Custom MIME headers. */
|
|
69
92
|
readonly headers: Record<string, string>;
|
|
93
|
+
/** Marks this email as sent for callers tracking queued send state. */
|
|
70
94
|
setSent: () => void;
|
|
95
|
+
/** Marks this email as failed for callers tracking queued send state. */
|
|
71
96
|
setSentError: (e: unknown) => void;
|
|
97
|
+
/** Resolves when the email has been sent by a mailer. */
|
|
72
98
|
sent: Promise<void>;
|
|
99
|
+
/** Creates a MIME message builder from high-level email options. */
|
|
73
100
|
constructor(options: EmailOptions);
|
|
74
101
|
private static toUsers;
|
|
75
102
|
private static toEnvelopeRecipients;
|
|
103
|
+
/** Returns MIME message data without SMTP dot-stuffing. */
|
|
76
104
|
getMessageData(): string;
|
|
105
|
+
/** Returns MIME message data, resolving Blob attachment content first. */
|
|
77
106
|
getMessageDataAsync(): Promise<string>;
|
|
78
107
|
private buildMessageData;
|
|
79
108
|
private resolveAttachments;
|
|
@@ -87,8 +116,11 @@ declare class Email {
|
|
|
87
116
|
private bytesToWrappedBase64;
|
|
88
117
|
private bytesToBase64;
|
|
89
118
|
private wrapBase64;
|
|
119
|
+
/** Returns SMTP DATA payload with dot-stuffing and final terminator. */
|
|
90
120
|
getEmailData(): string;
|
|
121
|
+
/** Returns SMTP DATA payload after resolving async attachment content. */
|
|
91
122
|
getEmailDataAsync(): Promise<string>;
|
|
123
|
+
/** Dot-stuffs MIME data and appends the SMTP DATA terminator. */
|
|
92
124
|
static toSmtpData(data: string): string;
|
|
93
125
|
private static applyDotStuffing;
|
|
94
126
|
private generateSafeBoundary;
|
|
@@ -101,15 +133,19 @@ declare class Email {
|
|
|
101
133
|
private resolveCC;
|
|
102
134
|
}
|
|
103
135
|
|
|
136
|
+
/** DKIM signing options for RSA-SHA256 signatures. */
|
|
104
137
|
type DkimConfig = {
|
|
105
138
|
domainName: string;
|
|
106
139
|
keySelector: string;
|
|
107
140
|
privateKey: string;
|
|
108
141
|
headerFieldNames?: string[];
|
|
109
142
|
};
|
|
143
|
+
/** Validates DKIM configuration before message signing. */
|
|
110
144
|
declare function validateDkimConfig(dkim: DkimConfig | undefined): void;
|
|
145
|
+
/** Returns a MIME message prefixed with a DKIM-Signature header. */
|
|
111
146
|
declare function signDkimMessage(message: string, dkim: DkimConfig): Promise<string>;
|
|
112
147
|
|
|
148
|
+
/** Verbosity levels for SMTP client logging. */
|
|
113
149
|
declare enum LogLevel {
|
|
114
150
|
DEBUG = 0,
|
|
115
151
|
INFO = 1,
|
|
@@ -118,7 +154,9 @@ declare enum LogLevel {
|
|
|
118
154
|
NONE = 4
|
|
119
155
|
}
|
|
120
156
|
|
|
157
|
+
/** TLS mode requested from a runtime socket adapter. */
|
|
121
158
|
type SocketTlsMode = 'off' | 'on' | 'starttls';
|
|
159
|
+
/** Minimal readable/writable socket contract used by the SMTP core. */
|
|
122
160
|
type EdgeSocket = {
|
|
123
161
|
readable: ReadableStream<Uint8Array>;
|
|
124
162
|
writable: WritableStream<Uint8Array>;
|
|
@@ -127,24 +165,30 @@ type EdgeSocket = {
|
|
|
127
165
|
close(reason?: unknown): Promise<void> | void;
|
|
128
166
|
startTls?(): EdgeSocket | Promise<EdgeSocket>;
|
|
129
167
|
};
|
|
168
|
+
/** Runtime socket connection request. */
|
|
130
169
|
type EdgeSocketConnectOptions = {
|
|
131
170
|
hostname: string;
|
|
132
171
|
port: number;
|
|
133
172
|
tls: SocketTlsMode;
|
|
134
173
|
signal?: AbortSignal;
|
|
135
174
|
};
|
|
175
|
+
/** Runtime adapter that opens SMTP TCP/TLS sockets. */
|
|
136
176
|
type EdgeSocketConnector = {
|
|
137
177
|
connect(options: EdgeSocketConnectOptions): EdgeSocket | Promise<EdgeSocket>;
|
|
138
178
|
};
|
|
139
179
|
|
|
180
|
+
/** SMTP authentication mechanisms supported by the shared SMTP client. */
|
|
140
181
|
type AuthType = 'plain' | 'login' | 'cram-md5';
|
|
182
|
+
/** Username and password used for SMTP AUTH. */
|
|
141
183
|
type Credentials = {
|
|
142
184
|
username: string;
|
|
143
185
|
password: string;
|
|
144
186
|
};
|
|
187
|
+
/** Controls ordered batch behavior when one message fails. */
|
|
145
188
|
type BatchSendOptions = {
|
|
146
189
|
continueOnError?: boolean;
|
|
147
190
|
};
|
|
191
|
+
/** Recipient rejected by the SMTP server during the envelope phase. */
|
|
148
192
|
type SmtpRejectedRecipient = {
|
|
149
193
|
recipient: string;
|
|
150
194
|
response: string;
|
|
@@ -152,6 +196,7 @@ type SmtpRejectedRecipient = {
|
|
|
152
196
|
enhancedStatusCode?: string;
|
|
153
197
|
transient: boolean;
|
|
154
198
|
};
|
|
199
|
+
/** Structured receipt returned after an SMTP DATA transaction completes. */
|
|
155
200
|
type SmtpSendReceipt = {
|
|
156
201
|
messageId: string;
|
|
157
202
|
envelope: {
|
|
@@ -165,26 +210,40 @@ type SmtpSendReceipt = {
|
|
|
165
210
|
enhancedStatusCode?: string;
|
|
166
211
|
size: number;
|
|
167
212
|
};
|
|
213
|
+
/** Ordered result list returned by `sendBatch()` and `sendMany()`. */
|
|
168
214
|
type BatchSendResult = PromiseSettledResult<SmtpSendReceipt>[];
|
|
215
|
+
/** SMTP PIPELINING behavior. */
|
|
169
216
|
type PipeliningMode = 'auto' | false;
|
|
217
|
+
/** SMTP message body encoding advertised in MAIL FROM. */
|
|
170
218
|
type SmtpBodyType = '7BIT' | '8BITMIME';
|
|
219
|
+
/** Protocol stage attached to structured SMTP errors. */
|
|
171
220
|
type SMTPStage = 'connect' | 'greet' | 'ehlo' | 'helo' | 'starttls' | 'auth' | 'mail' | 'rcpt' | 'data' | 'body' | 'rset' | 'quit' | 'send' | 'read';
|
|
221
|
+
/** Constructor details for {@link SMTPError}. */
|
|
172
222
|
type SMTPErrorOptions = {
|
|
173
223
|
stage: SMTPStage;
|
|
174
224
|
command?: string;
|
|
175
225
|
response?: string;
|
|
176
226
|
cause?: unknown;
|
|
177
227
|
};
|
|
228
|
+
/** Error thrown when an SMTP command or socket stage fails. */
|
|
178
229
|
declare class SMTPError extends Error {
|
|
230
|
+
/** SMTP stage where the failure happened. */
|
|
179
231
|
readonly stage: SMTPStage;
|
|
232
|
+
/** SMTP command active when the failure happened, when available. */
|
|
180
233
|
readonly command?: string;
|
|
234
|
+
/** Raw SMTP response line associated with the failure. */
|
|
181
235
|
readonly response?: string;
|
|
236
|
+
/** Three-digit SMTP response code parsed from {@link response}. */
|
|
182
237
|
readonly responseCode?: number;
|
|
238
|
+
/** Enhanced status code parsed from {@link response}. */
|
|
183
239
|
readonly enhancedStatusCode?: string;
|
|
240
|
+
/** Whether the response code is a transient 4xx failure. */
|
|
184
241
|
readonly transient: boolean;
|
|
185
242
|
readonly cause?: unknown;
|
|
243
|
+
/** Creates a structured SMTP error. */
|
|
186
244
|
constructor(message: string, options: SMTPErrorOptions);
|
|
187
245
|
}
|
|
246
|
+
/** SMTP client configuration shared by Cloudflare and Deno runtimes. */
|
|
188
247
|
type EdgeMailerOptions = {
|
|
189
248
|
host: string;
|
|
190
249
|
port: number;
|
|
@@ -200,11 +259,13 @@ type EdgeMailerOptions = {
|
|
|
200
259
|
socketTimeoutMs?: number;
|
|
201
260
|
responseTimeoutMs?: number;
|
|
202
261
|
};
|
|
262
|
+
/** Connection-pool limits for repeated SMTP sends. */
|
|
203
263
|
type SmtpPoolOptions = {
|
|
204
264
|
maxConnections?: number;
|
|
205
265
|
maxMessagesPerConnection?: number;
|
|
206
266
|
idleTimeoutMs?: number;
|
|
207
267
|
};
|
|
268
|
+
/** Runtime-neutral SMTP session implementation used by runtime mailers. */
|
|
208
269
|
declare class SmtpMailer {
|
|
209
270
|
private readonly connector;
|
|
210
271
|
private readonly host;
|
|
@@ -240,9 +301,13 @@ declare class SmtpMailer {
|
|
|
240
301
|
private supportsStartTls;
|
|
241
302
|
private supportsPipelining;
|
|
242
303
|
protected constructor(options: EdgeMailerOptions, connector: EdgeSocketConnector, runtimeName?: string);
|
|
304
|
+
/** Sends one message over the active SMTP session. */
|
|
243
305
|
send(options: EmailOptions): Promise<SmtpSendReceipt>;
|
|
306
|
+
/** Sends messages sequentially over the active SMTP session. */
|
|
244
307
|
sendMany(emails: EmailOptions[], options?: BatchSendOptions): Promise<BatchSendResult>;
|
|
308
|
+
/** Closes the SMTP socket and rejects any queued sends. */
|
|
245
309
|
close(error?: Error): Promise<void>;
|
|
310
|
+
/** Returns whether the SMTP session is open and usable. */
|
|
246
311
|
isActive(): boolean;
|
|
247
312
|
protected initializeSmtpSession(): Promise<void>;
|
|
248
313
|
private sendEmail;
|
|
@@ -291,6 +356,7 @@ declare class SmtpMailer {
|
|
|
291
356
|
private getSocket;
|
|
292
357
|
}
|
|
293
358
|
|
|
359
|
+
/** Bounded SMTP connection pool for reusing runtime mailer sessions. */
|
|
294
360
|
declare class SmtpConnectionPool<TMailer extends SmtpMailer> {
|
|
295
361
|
private readonly options;
|
|
296
362
|
private readonly connectMailer;
|
|
@@ -305,8 +371,11 @@ declare class SmtpConnectionPool<TMailer extends SmtpMailer> {
|
|
|
305
371
|
private totalConnections;
|
|
306
372
|
private closed;
|
|
307
373
|
constructor(options: EdgeMailerOptions, connectMailer: (options: EdgeMailerOptions) => Promise<TMailer>);
|
|
374
|
+
/** Sends one message through an acquired SMTP session. */
|
|
308
375
|
send(email: Parameters<TMailer['send']>[0]): Promise<SmtpSendReceipt>;
|
|
376
|
+
/** Sends messages sequentially through the pool. */
|
|
309
377
|
sendMany(emails: Parameters<TMailer['send']>[0][], options?: BatchSendOptions): Promise<BatchSendResult>;
|
|
378
|
+
/** Closes all pooled SMTP sessions and rejects queued sends. */
|
|
310
379
|
close(): Promise<void>;
|
|
311
380
|
private acquire;
|
|
312
381
|
private release;
|
package/package.json
CHANGED