@upyo/smtp 0.1.0-dev.10 → 0.1.0-dev.12
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/README.md +15 -44
- package/dist/index.cjs +7 -7
- package/dist/index.js +7 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
@upyo/smtp
|
|
4
4
|
==========
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
7
|
+
[![npm][npm badge]][npm]
|
|
8
|
+
|
|
9
|
+
SMTP transport implementation for the [Upyo] email library.
|
|
10
|
+
|
|
11
|
+
[JSR]: https://jsr.io/@upyo/smtp
|
|
12
|
+
[JSR badge]: https://jsr.io/badges/@upyo/smtp
|
|
13
|
+
[npm]: https://www.npmjs.com/package/@upyo/smtp
|
|
14
|
+
[npm badge]: https://img.shields.io/npm/v/@upyo/smtp?logo=npm
|
|
15
|
+
[Upyo]: https://upyo.org/
|
|
7
16
|
|
|
8
17
|
|
|
9
18
|
Features
|
|
@@ -47,8 +56,8 @@ Usage
|
|
|
47
56
|
### Basic Email Sending
|
|
48
57
|
|
|
49
58
|
~~~~ typescript
|
|
59
|
+
import { createMessage } from "@upyo/core";
|
|
50
60
|
import { SmtpTransport } from "@upyo/smtp";
|
|
51
|
-
import { type Message } from "@upyo/core";
|
|
52
61
|
|
|
53
62
|
const transport = new SmtpTransport({
|
|
54
63
|
host: "smtp.example.com",
|
|
@@ -60,55 +69,17 @@ const transport = new SmtpTransport({
|
|
|
60
69
|
},
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
const message
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
ccRecipients: [],
|
|
67
|
-
bccRecipients: [],
|
|
68
|
-
replyRecipients: [],
|
|
72
|
+
const message = createMessage({
|
|
73
|
+
from: "sender@example.com",
|
|
74
|
+
to: "recipient@example.net",
|
|
69
75
|
subject: "Hello from Upyo!",
|
|
70
76
|
content: { text: "This is a test email." },
|
|
71
|
-
|
|
72
|
-
priority: "normal",
|
|
73
|
-
tags: [],
|
|
74
|
-
headers: new Headers(),
|
|
75
|
-
};
|
|
77
|
+
});
|
|
76
78
|
|
|
77
79
|
const receipt = await transport.send(message);
|
|
78
80
|
console.log("Email sent:", receipt.successful);
|
|
79
81
|
~~~~
|
|
80
82
|
|
|
81
|
-
### HTML Email with Attachments
|
|
82
|
-
|
|
83
|
-
~~~~ typescript
|
|
84
|
-
const message: Message = {
|
|
85
|
-
sender: { address: "sender@example.com" },
|
|
86
|
-
recipients: [{ address: "recipient@example.com" }],
|
|
87
|
-
ccRecipients: [],
|
|
88
|
-
bccRecipients: [],
|
|
89
|
-
replyRecipients: [],
|
|
90
|
-
subject: "HTML Email with Attachment",
|
|
91
|
-
content: {
|
|
92
|
-
html: "<h1>Hello!</h1><p>This is an <strong>HTML</strong> email.</p>",
|
|
93
|
-
text: "Hello!\nThis is an HTML email.",
|
|
94
|
-
},
|
|
95
|
-
attachments: [
|
|
96
|
-
{
|
|
97
|
-
filename: "document.pdf",
|
|
98
|
-
content: new Uint8Array(pdfBytes),
|
|
99
|
-
contentType: "application/pdf",
|
|
100
|
-
contentId: "doc1",
|
|
101
|
-
inline: false,
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
priority: "high",
|
|
105
|
-
tags: ["newsletter"],
|
|
106
|
-
headers: new Headers([["X-Campaign-ID", "12345"]]),
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const receipt = await transport.send(message);
|
|
110
|
-
~~~~
|
|
111
|
-
|
|
112
83
|
### Sending Multiple Emails
|
|
113
84
|
|
|
114
85
|
~~~~ typescript
|
package/dist/index.cjs
CHANGED
|
@@ -266,7 +266,7 @@ var SmtpConnection = class {
|
|
|
266
266
|
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/message-converter.ts
|
|
269
|
-
function convertMessage(message) {
|
|
269
|
+
async function convertMessage(message) {
|
|
270
270
|
const envelope = {
|
|
271
271
|
from: message.sender.address,
|
|
272
272
|
to: [
|
|
@@ -275,13 +275,13 @@ function convertMessage(message) {
|
|
|
275
275
|
...message.bccRecipients.map((r) => r.address)
|
|
276
276
|
]
|
|
277
277
|
};
|
|
278
|
-
const raw = buildRawMessage(message);
|
|
278
|
+
const raw = await buildRawMessage(message);
|
|
279
279
|
return {
|
|
280
280
|
envelope,
|
|
281
281
|
raw
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
function buildRawMessage(message) {
|
|
284
|
+
async function buildRawMessage(message) {
|
|
285
285
|
const lines = [];
|
|
286
286
|
const boundary = generateBoundary();
|
|
287
287
|
const hasAttachments = message.attachments.length > 0;
|
|
@@ -346,7 +346,7 @@ function buildRawMessage(message) {
|
|
|
346
346
|
lines.push(`Content-ID: <${attachment.contentId}>`);
|
|
347
347
|
} else lines.push(`Content-Disposition: attachment; filename="${attachment.filename}"`);
|
|
348
348
|
lines.push("");
|
|
349
|
-
lines.push(encodeBase64(attachment.content));
|
|
349
|
+
lines.push(encodeBase64(await attachment.content));
|
|
350
350
|
}
|
|
351
351
|
lines.push("");
|
|
352
352
|
lines.push(`--${boundary}--`);
|
|
@@ -472,7 +472,7 @@ var SmtpTransport = class {
|
|
|
472
472
|
const connection = await this.getConnection(options?.signal);
|
|
473
473
|
try {
|
|
474
474
|
options?.signal?.throwIfAborted();
|
|
475
|
-
const smtpMessage = convertMessage(message);
|
|
475
|
+
const smtpMessage = await convertMessage(message);
|
|
476
476
|
options?.signal?.throwIfAborted();
|
|
477
477
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
478
478
|
await this.returnConnection(connection);
|
|
@@ -535,7 +535,7 @@ var SmtpTransport = class {
|
|
|
535
535
|
continue;
|
|
536
536
|
}
|
|
537
537
|
try {
|
|
538
|
-
const smtpMessage = convertMessage(message);
|
|
538
|
+
const smtpMessage = await convertMessage(message);
|
|
539
539
|
options?.signal?.throwIfAborted();
|
|
540
540
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
541
541
|
yield {
|
|
@@ -563,7 +563,7 @@ var SmtpTransport = class {
|
|
|
563
563
|
continue;
|
|
564
564
|
}
|
|
565
565
|
try {
|
|
566
|
-
const smtpMessage = convertMessage(message);
|
|
566
|
+
const smtpMessage = await convertMessage(message);
|
|
567
567
|
options?.signal?.throwIfAborted();
|
|
568
568
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
569
569
|
yield {
|
package/dist/index.js
CHANGED
|
@@ -243,7 +243,7 @@ var SmtpConnection = class {
|
|
|
243
243
|
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/message-converter.ts
|
|
246
|
-
function convertMessage(message) {
|
|
246
|
+
async function convertMessage(message) {
|
|
247
247
|
const envelope = {
|
|
248
248
|
from: message.sender.address,
|
|
249
249
|
to: [
|
|
@@ -252,13 +252,13 @@ function convertMessage(message) {
|
|
|
252
252
|
...message.bccRecipients.map((r) => r.address)
|
|
253
253
|
]
|
|
254
254
|
};
|
|
255
|
-
const raw = buildRawMessage(message);
|
|
255
|
+
const raw = await buildRawMessage(message);
|
|
256
256
|
return {
|
|
257
257
|
envelope,
|
|
258
258
|
raw
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
function buildRawMessage(message) {
|
|
261
|
+
async function buildRawMessage(message) {
|
|
262
262
|
const lines = [];
|
|
263
263
|
const boundary = generateBoundary();
|
|
264
264
|
const hasAttachments = message.attachments.length > 0;
|
|
@@ -323,7 +323,7 @@ function buildRawMessage(message) {
|
|
|
323
323
|
lines.push(`Content-ID: <${attachment.contentId}>`);
|
|
324
324
|
} else lines.push(`Content-Disposition: attachment; filename="${attachment.filename}"`);
|
|
325
325
|
lines.push("");
|
|
326
|
-
lines.push(encodeBase64(attachment.content));
|
|
326
|
+
lines.push(encodeBase64(await attachment.content));
|
|
327
327
|
}
|
|
328
328
|
lines.push("");
|
|
329
329
|
lines.push(`--${boundary}--`);
|
|
@@ -449,7 +449,7 @@ var SmtpTransport = class {
|
|
|
449
449
|
const connection = await this.getConnection(options?.signal);
|
|
450
450
|
try {
|
|
451
451
|
options?.signal?.throwIfAborted();
|
|
452
|
-
const smtpMessage = convertMessage(message);
|
|
452
|
+
const smtpMessage = await convertMessage(message);
|
|
453
453
|
options?.signal?.throwIfAborted();
|
|
454
454
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
455
455
|
await this.returnConnection(connection);
|
|
@@ -512,7 +512,7 @@ var SmtpTransport = class {
|
|
|
512
512
|
continue;
|
|
513
513
|
}
|
|
514
514
|
try {
|
|
515
|
-
const smtpMessage = convertMessage(message);
|
|
515
|
+
const smtpMessage = await convertMessage(message);
|
|
516
516
|
options?.signal?.throwIfAborted();
|
|
517
517
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
518
518
|
yield {
|
|
@@ -540,7 +540,7 @@ var SmtpTransport = class {
|
|
|
540
540
|
continue;
|
|
541
541
|
}
|
|
542
542
|
try {
|
|
543
|
-
const smtpMessage = convertMessage(message);
|
|
543
|
+
const smtpMessage = await convertMessage(message);
|
|
544
544
|
options?.signal?.throwIfAborted();
|
|
545
545
|
const messageId = await connection.sendMessage(smtpMessage, options?.signal);
|
|
546
546
|
yield {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/smtp",
|
|
3
|
-
"version": "0.1.0-dev.
|
|
3
|
+
"version": "0.1.0-dev.12+d36debdf",
|
|
4
4
|
"description": "SMTP transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.1.0-dev.
|
|
56
|
+
"@upyo/core": "0.1.0-dev.12+d36debdf"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@dotenvx/dotenvx": "^1.47.3",
|