-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtransactional.ts
More file actions
37 lines (33 loc) · 910 Bytes
/
transactional.ts
File metadata and controls
37 lines (33 loc) · 910 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
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 client = new MailtrapClient({ token: TOKEN });
client.batchSend({
base: {
from: { name: "Mailtrap Test", email: SENDER_EMAIL },
subject: "Transactional Email",
text: "Welcome to Mailtrap 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);