File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ Refer to the [`examples`](examples) folder for the source code of this and other
6666 - [ Send email using template] ( examples/sending/template.ts )
6767 - [ Nodemailer transport] ( examples/sending/transport.ts )
6868
69+ ### Batch Sending API
70+
71+ - [ Send a batch of transactional emails] ( examples/batch/transactional.ts )
72+ - [ Send a batch of bulk emails] ( examples/batch/bulk.ts )
73+ - [ Send a batch of sandbox emails] ( examples/batch/sandbox.ts )
74+ - [ Send a batch of emails from template] ( examples/batch/template.ts )
75+
6976### Email testing API
7077
7178 - [ Attachments] ( examples/testing/attachments.ts )
Original file line number Diff line number Diff line change 1+ import { MailtrapClient } from "mailtrap" ;
2+
3+ /**
4+ * For this example, you need to have ready-to-use sending domain or,
5+ * a Demo domain that allows sending emails to your own account email.
6+ * @see https://help.mailtrap.io/article/69-sending-domain-setup
7+ */
8+
9+ const TOKEN = "<YOUR-TOKEN-HERE>" ;
10+ const SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>" ;
11+ const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>" ;
12+
13+ const client = new MailtrapClient ( {
14+ token : TOKEN ,
15+ } ) ;
16+
17+ client . batchSend ( {
18+ base : {
19+ from : { name : "Mailtrap Test" , email : SENDER_EMAIL } ,
20+ subject : "Sandbox Email" ,
21+ text : "Welcome to Mailtrap Sandbox Batch Sending!"
22+ } ,
23+ requests : [
24+ {
25+ to : [ { email : RECIPIENT_EMAIL } ] ,
26+ custom_variables : {
27+ email_number : 1
28+ }
29+ } ,
30+ {
31+ to : [ { email : RECIPIENT_EMAIL } ] ,
32+ custom_variables : {
33+ email_number : 2
34+ }
35+ }
36+ ]
37+ } )
38+ . then ( console . log )
39+ . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ import { MailtrapClient } from "mailtrap" ;
2+
3+ /**
4+ * For this example, you need to have ready-to-use sending domain or,
5+ * a Demo domain that allows sending emails to your own account email.
6+ * @see https://help.mailtrap.io/article/69-sending-domain-setup
7+ */
8+
9+ const TOKEN = "<YOUR-TOKEN-HERE>" ;
10+ const TEST_INBOX_ID = "<YOUR-TEST-INBOX-ID-HERE>" ;
11+ const SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>" ;
12+ const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>" ;
13+
14+ const client = new MailtrapClient ( {
15+ token : TOKEN ,
16+ sandbox : true ,
17+ testInboxId : TEST_INBOX_ID
18+ } ) ;
19+
20+ client . batchSend ( {
21+ base : {
22+ from : { name : "Mailtrap Test" , email : SENDER_EMAIL } ,
23+ subject : "Sandbox Email" ,
24+ text : "Welcome to Mailtrap Sandbox Batch Sending!"
25+ } ,
26+ requests : [
27+ {
28+ to : [ { email : RECIPIENT_EMAIL } ] ,
29+ custom_variables : {
30+ email_number : 1
31+ }
32+ } ,
33+ {
34+ to : [ { email : RECIPIENT_EMAIL } ] ,
35+ custom_variables : {
36+ email_number : 2
37+ }
38+ }
39+ ]
40+ } )
41+ . then ( console . log )
42+ . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ import { MailtrapClient } from "mailtrap" ;
2+
3+ /**
4+ * For this example, you need to have ready-to-use sending domain or,
5+ * a Demo domain that allows sending emails to your own account email.
6+ * @see https://help.mailtrap.io/article/69-sending-domain-setup
7+ */
8+
9+ const TOKEN = "<YOUR-TOKEN-HERE>" ;
10+ const SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>" ;
11+ const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>" ;
12+ const TEMPLATE_UUID = "<TEMPLATE-UUID>" ;
13+
14+ const client = new MailtrapClient ( { token : TOKEN } ) ;
15+
16+ client . batchSend ( {
17+ base : {
18+ from : { name : "Mailtrap Test" , email : SENDER_EMAIL } ,
19+ template_uuid : TEMPLATE_UUID
20+ } ,
21+ requests : [
22+ {
23+ to : [ { email : RECIPIENT_EMAIL } ] ,
24+ template_variables : {
25+ user_name : "John Doe" ,
26+ company_name : "Example Corp"
27+ }
28+ } ,
29+ {
30+ to : [ { email : RECIPIENT_EMAIL } ] ,
31+ template_variables : {
32+ user_name : "Jane Smith" ,
33+ company_name : "Example Corp"
34+ }
35+ }
36+ ]
37+ } )
38+ . then ( console . log )
39+ . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1+ import { MailtrapClient } from "mailtrap" ;
2+
3+ /**
4+ * For this example, you need to have ready-to-use sending domain or,
5+ * a Demo domain that allows sending emails to your own account email.
6+ * @see https://help.mailtrap.io/article/69-sending-domain-setup
7+ */
8+
9+ const TOKEN = "<YOUR-TOKEN-HERE>" ;
10+ const SENDER_EMAIL = "<SENDER@YOURDOMAIN.COM>" ;
11+ const RECIPIENT_EMAIL = "<RECIPIENT@EMAIL.COM>" ;
12+
13+ const client = new MailtrapClient ( { token : TOKEN } ) ;
14+
15+ client . batchSend ( {
16+ base : {
17+ from : { name : "Mailtrap Test" , email : SENDER_EMAIL } ,
18+ subject : "Transactional Email" ,
19+ text : "Welcome to Mailtrap Batch Sending!"
20+ } ,
21+ requests : [
22+ {
23+ to : [ { email : RECIPIENT_EMAIL } ] ,
24+ custom_variables : {
25+ email_number : 1
26+ }
27+ } ,
28+ {
29+ to : [ { email : RECIPIENT_EMAIL } ] ,
30+ custom_variables : {
31+ email_number : 2
32+ }
33+ }
34+ ]
35+ } )
36+ . then ( console . log )
37+ . catch ( console . error ) ;
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ import { MailtrapClient } from "mailtrap"
44 * For this example, you need to have ready-to-use sending domain or,
55 * a Demo domain that allows sending emails to your own account email.
66 * @see https://help.mailtrap.io/article/69-sending-domain-setup
7+ * @see https://help.mailtrap.io/article/69-sending-domain-setup#Demo-Domain--oYOU5"
78 */
89
9- ", @see https://help.mailtrap.io/article/69-sending-domain-setup#Demo-Domain--oYOU5"
1010
1111const TOKEN = "<YOUR-TOKEN-HERE>" ;
1212const TEST_INBOX_ID = "<YOUR-TEST-INBOX-ID-HERE>"
You can’t perform that action at this time.
0 commit comments