-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathindex.mjs
More file actions
28 lines (22 loc) · 739 Bytes
/
index.mjs
File metadata and controls
28 lines (22 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { MailtrapClient } from "mailtrap";
/**
* For this example to work, you need to set up a sending domain,
* and obtain a token that is authorized to send from the domain.
*/
const TOKEN = "05bf3445ae1a9814ecf445a6272a9db7";
const SENDER_EMAIL = "hello@demomailtrap.com";
const RECIPIENT_EMAIL = "mendsalbert@gmail.com";
if (!TOKEN) {
throw new Error("MAILTRAP_TOKEN environment variable is not set");
}
const client = new MailtrapClient({ token: TOKEN });
const sender = { name: "Mailtrap Test", email: SENDER_EMAIL };
client
.send({
from: sender,
to: [{ email: RECIPIENT_EMAIL }],
subject: "Hello from Mailtrap!",
text: "Welcome to Mailtrap Sending!",
})
.then(console.log)
.catch(console.error);