-
Notifications
You must be signed in to change notification settings - Fork 11
Batch Sending Api #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
narekhovhannisyan
wants to merge
33
commits into
main
Choose a base branch
from
batch-sending-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b38e2a6
types: add BatchMail and BatchSendResponse types to mailtrap
narekhovhannisyan 927d95e
feat: implement batchSend method for sending multiple emails
narekhovhannisyan 2cc5795
feat: add BATCH_ENDPOINT to client settings for batch email sending
narekhovhannisyan 62df618
test: add unit test for batch email sending functionality in Mailtrap…
narekhovhannisyan f88e2ca
feat: add example for batch email sending using MailtrapClient
narekhovhannisyan 268a293
docs: update README to include batch sending API example
narekhovhannisyan ec88054
feat: add bulk email sending example using MailtrapClient
narekhovhannisyan 0240468
examples: create sandbox example for batch email sending with Mailtra…
narekhovhannisyan ebb20da
fix: add missing newline at end of file in bulk email sending example
narekhovhannisyan 563f4fa
revert: remove deprecated batch email sending example from examples d…
narekhovhannisyan 2980312
examples: add new batch email sending template example using Mailtrap…
narekhovhannisyan 2a873f1
examples: add new transactional email sending example using MailtrapC…
narekhovhannisyan 87c868b
fix: update documentation link in send-mail example for clarity
narekhovhannisyan 0b39bab
chore: remove deprecated BATCH_ENDPOINT from configuration
narekhovhannisyan 7fbe71a
refactor: change encodeMailBuffers function to accept Partial<Mail> type
narekhovhannisyan 22db43b
refactor: update batchSend method to accept BatchSendRequest and rest…
narekhovhannisyan 5802797
types: add BatchSendRequest and BatchSendRequestItem types for batch …
narekhovhannisyan 4c78bad
test: enhance batch email sending tests with various scenarios and er…
narekhovhannisyan d5a6c1b
docs: update README to include new examples for sending transactional…
narekhovhannisyan 3550280
types: refactor BatchSendRequest to use BaseAddress and separate inli…
narekhovhannisyan dea8728
test: add error handling test for incompatible bulk and sandbox modes…
narekhovhannisyan efce27f
test: remove redundant batch email sending test case
narekhovhannisyan 6494340
types: add custom_variables field to BatchSendRequest for enhanced fl…
narekhovhannisyan e5b087a
docs: update batch sample references
narekhovhannisyan 3a42d59
examples: remove redundant newline
narekhovhannisyan d122f6b
test: update batch email sending tests to reflect new response struct…
narekhovhannisyan fb1b5da
types: make base property optional in BatchSendRequest for improved f…
narekhovhannisyan d3838f3
types: extend BatchSendRequest with optional fields for enhanced emai…
narekhovhannisyan bf9828d
types: clarify category field usage in BatchSendRequest for inline an…
narekhovhannisyan fdd2cc9
types: extend InlineBatchSendBase and TemplateBatchSendBase to omit '…
narekhovhannisyan e033f59
fix: make base property in MailtrapClient optional to handle undefine…
narekhovhannisyan 8289f60
test: update MailtrapClient tests to use message_ids array and improv…
narekhovhannisyan 79484d4
types: refactor BatchSendResponse to use an interface with detailed s…
narekhovhannisyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 = "<[email protected]>"; | ||
const RECIPIENT_EMAIL = "<[email protected]>"; | ||
|
||
const client = new MailtrapClient({ | ||
token: TOKEN, | ||
}); | ||
|
||
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); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 = "<[email protected]>"; | ||
const RECIPIENT_EMAIL = "<[email protected]>"; | ||
|
||
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 = "<[email protected]>"; | ||
const RECIPIENT_EMAIL = "<[email protected]>"; | ||
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 SENDER_EMAIL = "<[email protected]>"; | ||
const RECIPIENT_EMAIL = "<[email protected]>"; | ||
|
||
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.