-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathsandbox.ts
More file actions
42 lines (38 loc) · 1013 Bytes
/
sandbox.ts
File metadata and controls
42 lines (38 loc) · 1013 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { MailtrapClient } from "mailtrap";
/**
* For this example, you need to have ready-to-use sending domain or,
* a Demo domain that allows sending emails to your own account email.
* @see https://help.mailtrap.io/article/69-sending-domain-setup
*/
const TOKEN = "<YOUR-TOKEN-HERE>";
const TEST_INBOX_ID = "<YOUR-TEST-INBOX-ID-HERE>";
const SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>";
const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>";
const client = new MailtrapClient({
token: TOKEN,
sandbox: true,
testInboxId: TEST_INBOX_ID
});
client.batchSend({
base: {
from: { name: "Mailtrap Test", email: SENDER_EMAIL },
subject: "Sandbox Email",
text: "Welcome to Mailtrap Sandbox Batch Sending!"
},
requests: [
{
to: [{ email: RECIPIENT_EMAIL }],
custom_variables: {
email_number: 1
}
},
{
to: [{ email: RECIPIENT_EMAIL }],
custom_variables: {
email_number: 2
}
}
]
})
.then(console.log)
.catch(console.error);