dx-mail 1.0.2 โ 1.0.3
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 +433 -104
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,30 +4,39 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
Fast temporary email client with realtime inbox updates
|
|
7
|
+
Fast temporary email client with realtime inbox updates.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
DX Mail lets you create temporary email inboxes, listen for incoming messages instantly, and integrate them into bots, dashboards, automation tools, or Node.js apps.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Perfect for Telegram bots, WhatsApp bots, web inboxes, OTP listeners, verification flows, testing tools, and custom mail automation.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## โจ Features
|
|
16
|
+
|
|
17
|
+
- ๐ Create random temporary email addresses
|
|
18
|
+
- ๐ท๏ธ Create custom email addresses
|
|
14
19
|
- โก Realtime inbox updates using WebSocket
|
|
15
|
-
- ๐ฅ
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
+
- ๐ฅ Read message history
|
|
21
|
+
- ๐ Supports plain text and HTML emails
|
|
22
|
+
- ๐ค Works great with Telegram and WhatsApp bots
|
|
23
|
+
- ๐งฉ Simple API, similar feeling to Express-style clients
|
|
24
|
+
- ๐ API key authentication
|
|
25
|
+
- ๐ฆ Lightweight Node.js client
|
|
20
26
|
|
|
21
27
|
---
|
|
22
28
|
|
|
23
|
-
Installation
|
|
29
|
+
## ๐ฆ Installation
|
|
24
30
|
|
|
31
|
+
```bash
|
|
25
32
|
npm install dx-mail
|
|
33
|
+
```
|
|
26
34
|
|
|
27
35
|
---
|
|
28
36
|
|
|
29
|
-
Quick Start
|
|
37
|
+
## ๐ Quick Start
|
|
30
38
|
|
|
39
|
+
```js
|
|
31
40
|
const dxMail = require("dx-mail");
|
|
32
41
|
|
|
33
42
|
const app = dxMail({
|
|
@@ -38,198 +47,488 @@ const app = dxMail({
|
|
|
38
47
|
async function main() {
|
|
39
48
|
const res = await app.createMail();
|
|
40
49
|
|
|
41
|
-
console.log("
|
|
50
|
+
console.log("Your email address:");
|
|
42
51
|
console.log(res.inbox.address);
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
main();
|
|
54
|
+
main().catch(console.error);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Example output:
|
|
58
|
+
|
|
59
|
+
```txt
|
|
60
|
+
m7fa8d3c21a@yourdomain.com
|
|
61
|
+
```
|
|
46
62
|
|
|
47
63
|
---
|
|
48
64
|
|
|
49
|
-
Authentication
|
|
65
|
+
## ๐ Authentication
|
|
50
66
|
|
|
51
|
-
|
|
67
|
+
You can pass your API key directly when creating the client.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const dxMail = require("dx-mail");
|
|
52
71
|
|
|
53
72
|
const app = dxMail({
|
|
54
73
|
baseUrl: "https://your-server.com",
|
|
55
74
|
token: "dxm_your_api_key"
|
|
56
75
|
});
|
|
76
|
+
```
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
Or use the chained style.
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const dxMail = require("dx-mail");
|
|
59
82
|
|
|
60
83
|
const app = dxMail();
|
|
61
84
|
|
|
62
85
|
app.setBaseUrl("https://your-server.com");
|
|
63
86
|
app.auth("dxm_your_api_key");
|
|
87
|
+
```
|
|
64
88
|
|
|
65
89
|
---
|
|
66
90
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
createMail()
|
|
70
|
-
|
|
71
|
-
Create a random email address.
|
|
91
|
+
## ๐ฎ Create a Random Email
|
|
72
92
|
|
|
93
|
+
```js
|
|
73
94
|
const res = await app.createMail();
|
|
74
95
|
|
|
75
96
|
console.log(res.inbox.address);
|
|
97
|
+
```
|
|
76
98
|
|
|
77
99
|
Example:
|
|
78
100
|
|
|
79
|
-
|
|
101
|
+
```txt
|
|
102
|
+
m9c81a7e231@yourdomain.com
|
|
103
|
+
```
|
|
80
104
|
|
|
81
105
|
---
|
|
82
106
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Create a custom email address.
|
|
107
|
+
## ๐ท๏ธ Create a Custom Email
|
|
86
108
|
|
|
87
|
-
|
|
109
|
+
```js
|
|
110
|
+
const res = await app.createMail("test1");
|
|
88
111
|
|
|
89
112
|
console.log(res.inbox.address);
|
|
113
|
+
```
|
|
90
114
|
|
|
91
|
-
|
|
115
|
+
Example:
|
|
92
116
|
|
|
93
|
-
|
|
117
|
+
```txt
|
|
118
|
+
test1@yourdomain.com
|
|
119
|
+
```
|
|
94
120
|
|
|
95
121
|
---
|
|
96
122
|
|
|
97
|
-
|
|
123
|
+
## ๐งต Callback Style
|
|
98
124
|
|
|
99
|
-
|
|
125
|
+
DX Mail supports both Promise and callback styles.
|
|
100
126
|
|
|
101
|
-
|
|
127
|
+
```js
|
|
128
|
+
app.createMail("test1", (res) => {
|
|
102
129
|
console.log(res.inbox.address);
|
|
103
130
|
});
|
|
131
|
+
```
|
|
104
132
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
app.createMail("test", (res) => {
|
|
110
|
-
console.log(res.inbox.address);
|
|
133
|
+
```js
|
|
134
|
+
app.listMail((res) => {
|
|
135
|
+
console.log(res.inboxes);
|
|
111
136
|
});
|
|
137
|
+
```
|
|
112
138
|
|
|
113
139
|
---
|
|
114
140
|
|
|
115
|
-
|
|
141
|
+
## ๐ List All Emails
|
|
116
142
|
|
|
117
143
|
Get all inboxes owned by your API key.
|
|
118
144
|
|
|
145
|
+
```js
|
|
119
146
|
const res = await app.listMail();
|
|
120
147
|
|
|
121
148
|
console.log(res.inboxes);
|
|
149
|
+
```
|
|
122
150
|
|
|
123
|
-
Example:
|
|
151
|
+
Example response:
|
|
124
152
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
153
|
+
```js
|
|
154
|
+
{
|
|
155
|
+
ok: true,
|
|
156
|
+
count: 2,
|
|
157
|
+
inboxes: [
|
|
158
|
+
{
|
|
159
|
+
id: "667f...",
|
|
160
|
+
name: "test1",
|
|
161
|
+
address: "test1@yourdomain.com",
|
|
162
|
+
domain: "yourdomain.com",
|
|
163
|
+
expiresAt: "2026-06-28T10:00:00.000Z",
|
|
164
|
+
createdAt: "2026-06-27T10:00:00.000Z"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
132
169
|
|
|
133
170
|
---
|
|
134
171
|
|
|
135
|
-
|
|
172
|
+
## ๐ฅ Read Messages
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
const res = await app.getMail("test1");
|
|
176
|
+
|
|
177
|
+
console.log(res.messages);
|
|
178
|
+
```
|
|
136
179
|
|
|
137
|
-
|
|
180
|
+
You can also use:
|
|
138
181
|
|
|
139
|
-
|
|
182
|
+
```js
|
|
183
|
+
const res = await app.getMessages("test1");
|
|
140
184
|
|
|
141
185
|
console.log(res.messages);
|
|
186
|
+
```
|
|
142
187
|
|
|
143
188
|
---
|
|
144
189
|
|
|
145
|
-
|
|
190
|
+
## โก Watch an Inbox Realtime
|
|
146
191
|
|
|
147
|
-
|
|
192
|
+
Listen for incoming emails instantly.
|
|
148
193
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
console.log(
|
|
194
|
+
```js
|
|
195
|
+
app.watchMail("test1", (event) => {
|
|
196
|
+
console.log("New email received!");
|
|
197
|
+
console.log("From:", event.message.from);
|
|
198
|
+
console.log("Subject:", event.message.subject);
|
|
199
|
+
console.log("Text:", event.message.text);
|
|
152
200
|
});
|
|
201
|
+
```
|
|
153
202
|
|
|
154
|
-
|
|
203
|
+
When an email arrives, you will receive an event like this:
|
|
155
204
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
205
|
+
```js
|
|
206
|
+
{
|
|
207
|
+
type: "mail.received",
|
|
208
|
+
inbox: {
|
|
209
|
+
id: "667f...",
|
|
210
|
+
name: "test1",
|
|
211
|
+
address: "test1@yourdomain.com"
|
|
212
|
+
},
|
|
213
|
+
message: {
|
|
214
|
+
id: "6680...",
|
|
215
|
+
to: "test1@yourdomain.com",
|
|
216
|
+
from: "noreply@example.com",
|
|
217
|
+
subject: "Welcome",
|
|
218
|
+
text: "Hello from DX Mail!",
|
|
219
|
+
html: "<p>Hello from DX Mail!</p>",
|
|
220
|
+
attachments: [],
|
|
221
|
+
receivedAt: "2026-06-27T14:00:00.000Z"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
159
225
|
|
|
160
226
|
---
|
|
161
227
|
|
|
162
|
-
|
|
228
|
+
## ๐ Stop Watching
|
|
163
229
|
|
|
164
|
-
|
|
230
|
+
`watchMail()` returns an unsubscribe function.
|
|
165
231
|
|
|
166
|
-
|
|
167
|
-
|
|
232
|
+
```js
|
|
233
|
+
const stop = app.watchMail("test1", (event) => {
|
|
234
|
+
console.log(event.message.subject);
|
|
168
235
|
});
|
|
169
236
|
|
|
170
|
-
|
|
237
|
+
stop();
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
171
241
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
242
|
+
## ๐ Watch All Inboxes
|
|
243
|
+
|
|
244
|
+
Listen to all inboxes owned by your API key.
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
const stop = app.watchAll((event) => {
|
|
248
|
+
console.log("Inbox:", event.inbox.address);
|
|
249
|
+
console.log("Subject:", event.message.subject);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
stop();
|
|
253
|
+
```
|
|
178
254
|
|
|
179
255
|
---
|
|
180
256
|
|
|
181
|
-
|
|
257
|
+
## โณ Wait for One Email
|
|
182
258
|
|
|
183
|
-
|
|
259
|
+
Useful for OTP, verification links, or test automation.
|
|
184
260
|
|
|
185
|
-
|
|
261
|
+
```js
|
|
262
|
+
const event = await app.waitMail("test1");
|
|
186
263
|
|
|
187
264
|
console.log(event.message.subject);
|
|
265
|
+
console.log(event.message.text);
|
|
266
|
+
```
|
|
188
267
|
|
|
189
268
|
With timeout:
|
|
190
269
|
|
|
191
|
-
|
|
270
|
+
```js
|
|
271
|
+
const event = await app.waitMail("test1", {
|
|
192
272
|
timeoutMs: 30000
|
|
193
273
|
});
|
|
274
|
+
```
|
|
194
275
|
|
|
195
276
|
---
|
|
196
277
|
|
|
197
|
-
|
|
278
|
+
## ๐ HTML Email Support
|
|
198
279
|
|
|
199
|
-
|
|
280
|
+
Many platforms send HTML emails. DX Mail supports both text and HTML bodies.
|
|
200
281
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
282
|
+
```js
|
|
283
|
+
app.watchMail("test1", (event) => {
|
|
284
|
+
if (event.message.html) {
|
|
285
|
+
console.log("HTML email received:");
|
|
286
|
+
console.log(event.message.html);
|
|
287
|
+
} else {
|
|
288
|
+
console.log(event.message.text);
|
|
289
|
+
}
|
|
204
290
|
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
For web inboxes, sanitize HTML before rendering it to users.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## ๐ค Telegram Bot Example
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
const dxMail = require("dx-mail");
|
|
301
|
+
|
|
302
|
+
const app = dxMail({
|
|
303
|
+
baseUrl: "https://your-server.com",
|
|
304
|
+
token: "dxm_your_api_key"
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
async function createUserMail(ctx) {
|
|
308
|
+
const res = await app.createMail();
|
|
309
|
+
|
|
310
|
+
await ctx.reply(`Your temporary email:\n${res.inbox.address}`);
|
|
311
|
+
|
|
312
|
+
app.watchMail(res.inbox.name, async (event) => {
|
|
313
|
+
await ctx.reply(
|
|
314
|
+
`๐ฉ New email!\n\nFrom: ${event.message.from}\nSubject: ${event.message.subject}\n\n${event.message.text}`
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## ๐ฌ WhatsApp Bot Example
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
const dxMail = require("dx-mail");
|
|
326
|
+
|
|
327
|
+
const app = dxMail({
|
|
328
|
+
baseUrl: "https://your-server.com",
|
|
329
|
+
token: "dxm_your_api_key"
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
async function createWhatsAppMail(sock, jid) {
|
|
333
|
+
const res = await app.createMail();
|
|
334
|
+
|
|
335
|
+
await sock.sendMessage(jid, {
|
|
336
|
+
text: `Your temporary email:\n${res.inbox.address}`
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
app.watchMail(res.inbox.name, async (event) => {
|
|
340
|
+
await sock.sendMessage(jid, {
|
|
341
|
+
text:
|
|
342
|
+
`๐ฉ New email!\n\n` +
|
|
343
|
+
`From: ${event.message.from}\n` +
|
|
344
|
+
`Subject: ${event.message.subject}\n\n` +
|
|
345
|
+
`${event.message.text}`
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
```
|
|
205
350
|
|
|
206
351
|
---
|
|
207
352
|
|
|
208
|
-
|
|
353
|
+
## ๐ฅ๏ธ Web Inbox Example
|
|
209
354
|
|
|
210
|
-
|
|
355
|
+
```js
|
|
356
|
+
const dxMail = require("dx-mail");
|
|
211
357
|
|
|
358
|
+
const app = dxMail({
|
|
359
|
+
baseUrl: "https://your-server.com",
|
|
360
|
+
token: "dxm_your_api_key"
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
app.watchMail("test1", (event) => {
|
|
364
|
+
renderMessage(event.message);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
function renderMessage(message) {
|
|
368
|
+
console.log(message.subject);
|
|
369
|
+
console.log(message.text);
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## ๐ง API Reference
|
|
376
|
+
|
|
377
|
+
### `dxMail(options)`
|
|
378
|
+
|
|
379
|
+
Create a new DX Mail client.
|
|
380
|
+
|
|
381
|
+
```js
|
|
382
|
+
const app = dxMail({
|
|
383
|
+
baseUrl: "https://your-server.com",
|
|
384
|
+
token: "dxm_your_api_key"
|
|
385
|
+
});
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### `app.auth(token)`
|
|
389
|
+
|
|
390
|
+
Set or update the API key.
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
app.auth("dxm_your_api_key");
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### `app.setBaseUrl(url)`
|
|
397
|
+
|
|
398
|
+
Set the DX Mail server URL.
|
|
399
|
+
|
|
400
|
+
```js
|
|
401
|
+
app.setBaseUrl("https://your-server.com");
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### `app.createMail(name?)`
|
|
405
|
+
|
|
406
|
+
Create a temporary inbox.
|
|
407
|
+
|
|
408
|
+
```js
|
|
409
|
+
await app.createMail();
|
|
410
|
+
await app.createMail("customname");
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### `app.listMail()`
|
|
414
|
+
|
|
415
|
+
List all inboxes owned by the API key.
|
|
416
|
+
|
|
417
|
+
```js
|
|
418
|
+
await app.listMail();
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### `app.getMail(name)`
|
|
422
|
+
|
|
423
|
+
Get messages from an inbox.
|
|
424
|
+
|
|
425
|
+
```js
|
|
426
|
+
await app.getMail("test1");
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### `app.getMessages(name)`
|
|
430
|
+
|
|
431
|
+
Alias for `getMail()`.
|
|
432
|
+
|
|
433
|
+
```js
|
|
434
|
+
await app.getMessages("test1");
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### `app.watchMail(name, callback)`
|
|
438
|
+
|
|
439
|
+
Watch one inbox in realtime.
|
|
440
|
+
|
|
441
|
+
```js
|
|
442
|
+
const stop = app.watchMail("test1", callback);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### `app.watchAll(callback)`
|
|
446
|
+
|
|
447
|
+
Watch all inboxes in realtime.
|
|
448
|
+
|
|
449
|
+
```js
|
|
450
|
+
const stop = app.watchAll(callback);
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### `app.waitMail(name, options?)`
|
|
454
|
+
|
|
455
|
+
Wait until one email arrives.
|
|
456
|
+
|
|
457
|
+
```js
|
|
458
|
+
const event = await app.waitMail("test1", {
|
|
459
|
+
timeoutMs: 60000
|
|
460
|
+
});
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### `app.close()`
|
|
464
|
+
|
|
465
|
+
Close the WebSocket connection.
|
|
466
|
+
|
|
467
|
+
```js
|
|
212
468
|
app.close();
|
|
469
|
+
```
|
|
213
470
|
|
|
214
471
|
---
|
|
215
472
|
|
|
216
|
-
|
|
473
|
+
## ๐ฆ Response Shapes
|
|
474
|
+
|
|
475
|
+
### Inbox
|
|
217
476
|
|
|
477
|
+
```js
|
|
218
478
|
{
|
|
219
|
-
id: "...",
|
|
220
|
-
|
|
479
|
+
id: "667f...",
|
|
480
|
+
name: "test1",
|
|
481
|
+
address: "test1@yourdomain.com",
|
|
482
|
+
domain: "yourdomain.com",
|
|
483
|
+
expiresAt: "2026-06-28T10:00:00.000Z",
|
|
484
|
+
createdAt: "2026-06-27T10:00:00.000Z"
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Message
|
|
489
|
+
|
|
490
|
+
```js
|
|
491
|
+
{
|
|
492
|
+
id: "6680...",
|
|
493
|
+
inboxId: "667f...",
|
|
494
|
+
to: "test1@yourdomain.com",
|
|
221
495
|
from: "noreply@example.com",
|
|
222
|
-
subject: "
|
|
223
|
-
text: "
|
|
224
|
-
html: "<
|
|
496
|
+
subject: "Welcome",
|
|
497
|
+
text: "Hello!",
|
|
498
|
+
html: "<p>Hello!</p>",
|
|
225
499
|
attachments: [],
|
|
226
|
-
receivedAt: "2026-06-27T14:00:00.000Z"
|
|
500
|
+
receivedAt: "2026-06-27T14:00:00.000Z",
|
|
501
|
+
createdAt: "2026-06-27T14:00:01.000Z"
|
|
227
502
|
}
|
|
503
|
+
```
|
|
228
504
|
|
|
229
505
|
---
|
|
230
506
|
|
|
231
|
-
|
|
507
|
+
## โ๏ธ Environment Variables
|
|
508
|
+
|
|
509
|
+
You can also configure the client using environment variables.
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
DX_MAIL_BASE_URL=https://your-server.com
|
|
513
|
+
DX_MAIL_TOKEN=dxm_your_api_key
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Then:
|
|
232
517
|
|
|
518
|
+
```js
|
|
519
|
+
const dxMail = require("dx-mail");
|
|
520
|
+
|
|
521
|
+
const app = dxMail();
|
|
522
|
+
|
|
523
|
+
const res = await app.createMail();
|
|
524
|
+
console.log(res.inbox.address);
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## ๐งช Full Example
|
|
530
|
+
|
|
531
|
+
```js
|
|
233
532
|
const dxMail = require("dx-mail");
|
|
234
533
|
|
|
235
534
|
const app = dxMail({
|
|
@@ -237,37 +536,67 @@ const app = dxMail({
|
|
|
237
536
|
token: "dxm_your_api_key"
|
|
238
537
|
});
|
|
239
538
|
|
|
240
|
-
|
|
539
|
+
async function main() {
|
|
540
|
+
const created = await app.createMail("demo");
|
|
541
|
+
|
|
542
|
+
console.log("Email created:", created.inbox.address);
|
|
241
543
|
|
|
242
|
-
app.watchMail(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
544
|
+
app.watchMail("demo", (event) => {
|
|
545
|
+
console.log("\n๐ฉ New email!");
|
|
546
|
+
console.log("From:", event.message.from);
|
|
547
|
+
console.log("Subject:", event.message.subject);
|
|
548
|
+
console.log("Text:", event.message.text);
|
|
549
|
+
console.log("HTML:", event.message.html ? "yes" : "no");
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
console.log("Waiting for emails...");
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
main().catch(console.error);
|
|
556
|
+
```
|
|
248
557
|
|
|
249
558
|
---
|
|
250
559
|
|
|
251
|
-
|
|
560
|
+
## ๐ Security Notes
|
|
252
561
|
|
|
253
|
-
|
|
254
|
-
|
|
562
|
+
- Do not expose your API key in public frontend apps.
|
|
563
|
+
- Use server-side bots or backend services when possible.
|
|
564
|
+
- Sanitize HTML before rendering emails in a browser.
|
|
565
|
+
- Rotate API keys if they are leaked.
|
|
566
|
+
- Do not commit `.env` files to GitHub.
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
## ๐งน Cleanup
|
|
571
|
+
|
|
572
|
+
Close the connection when your app shuts down.
|
|
573
|
+
|
|
574
|
+
```js
|
|
575
|
+
process.on("SIGINT", () => {
|
|
576
|
+
app.close();
|
|
577
|
+
process.exit(0);
|
|
255
578
|
});
|
|
579
|
+
```
|
|
256
580
|
|
|
257
581
|
---
|
|
258
582
|
|
|
259
|
-
|
|
583
|
+
## ๐ ๏ธ Built For
|
|
260
584
|
|
|
261
|
-
-
|
|
262
|
-
-
|
|
263
|
-
-
|
|
585
|
+
- Temporary email systems
|
|
586
|
+
- OTP listeners
|
|
587
|
+
- Verification email capture
|
|
588
|
+
- Telegram bots
|
|
589
|
+
- WhatsApp bots
|
|
590
|
+
- Web inbox dashboards
|
|
591
|
+
- Automation scripts
|
|
592
|
+
- Developer testing tools
|
|
264
593
|
|
|
265
594
|
---
|
|
266
595
|
|
|
267
|
-
License
|
|
596
|
+
## ๐ License
|
|
268
597
|
|
|
269
598
|
MIT
|
|
270
599
|
|
|
271
600
|
---
|
|
272
601
|
|
|
273
|
-
Made
|
|
602
|
+
Made for fast inbox experiments, bot builders, and people who enjoy turning email into realtime little lightning bolts. โก
|