-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtemplate.ts
More file actions
39 lines (35 loc) · 995 Bytes
/
template.ts
File metadata and controls
39 lines (35 loc) · 995 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
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 SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>";
const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>";
const TEMPLATE_UUID = "<TEMPLATE-UUID>";
const client = new MailtrapClient({ token: TOKEN });
client.batchSend({
base: {
from: { name: "Mailtrap Test", email: SENDER_EMAIL },
template_uuid: TEMPLATE_UUID
},
requests: [
{
to: [{ email: RECIPIENT_EMAIL }],
template_variables: {
user_name: "John Doe",
company_name: "Example Corp"
}
},
{
to: [{ email: RECIPIENT_EMAIL }],
template_variables: {
user_name: "Jane Smith",
company_name: "Example Corp"
}
}
]
})
.then(console.log)
.catch(console.error);