-
Notifications
You must be signed in to change notification settings - Fork 13
Restructure SDK #51
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
Merged
Merged
Restructure SDK #51
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b96f604
types: add bulk and sandbox flags to mailtrap
narekhovhannisyan 36a9df3
api: move testing send method to client
narekhovhannisyan 0b49830
api: drop bulk
narekhovhannisyan ef8e1b9
lib: refactor MailtrapClient to incapsulate bulk, sandbox send fnality
narekhovhannisyan dbd5fc6
config: add bulk sandbox incompatible message
narekhovhannisyan e8d764b
test: drop moved functionality from Testing
narekhovhannisyan 6f3dcd5
test: drop Bulk
narekhovhannisyan ce67277
test: cover new mailtrap client functionality with units
narekhovhannisyan e53b1c0
examples: fix mailtrap imports in testing
narekhovhannisyan 13fc15d
examples: fix mailtrap imports in general
narekhovhannisyan 10046b8
examples: update bulk sending example
narekhovhannisyan a5d4d20
docs: update Readme file, remove missing testing api notice
narekhovhannisyan 50c8c56
types: drop sending from additional fields
narekhovhannisyan 10f73e5
lib: drop switchable client
narekhovhannisyan a8b56bc
test: drop transport sandbox switch
narekhovhannisyan f24a304
examples: update transport sample
narekhovhannisyan b57bcfe
.github: configure codeql
narekhovhannisyan 9d00310
.github: configure codeql tests path
narekhovhannisyan 88e2acf
.github: add newline at the end of codeql config
narekhovhannisyan c2f1f89
.github: update codeql config to ignore all files in tests
narekhovhannisyan 16abea3
.github: drop codeql from test workflow
narekhovhannisyan 96d79a9
.github: tune codeql config
narekhovhannisyan f764542
WIP
7584350
.github: update codeql config path
narekhovhannisyan 51c959c
test: drop commented code from mailtrap client
narekhovhannisyan 7968a07
docs: move info on previous releases to the end of README
narekhovhannisyan 49e099d
lib: separate host detection logic from send method
narekhovhannisyan eed53c6
examples: init transport samples, send testing mail sample
narekhovhannisyan b03961e
examples: fix missing comma in transport
narekhovhannisyan febdb9e
src: fetch changes from main
narekhovhannisyan 9bc4687
.github: drop codeql from test workflow
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
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 |
|---|---|---|
|
|
@@ -12,9 +12,9 @@ const TOKEN = "<YOUR-TOKEN-HERE>"; | |
| const SENDER_EMAIL = "<[email protected]>"; | ||
| const RECIPIENT_EMAIL = "<[email protected]>"; | ||
|
|
||
| const client = new MailtrapClient({ token: TOKEN }); | ||
| const client = new MailtrapClient({ token: TOKEN, bulk: true }); | ||
|
|
||
| client.bulk.send({ | ||
| client.send({ | ||
| from: { name: "Mailtrap Test", email: SENDER_EMAIL }, | ||
| to: [{ email: RECIPIENT_EMAIL }], | ||
| subject: "Hello from Mailtrap!", | ||
|
|
||
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,60 @@ | ||
| import { readFileSync } from "fs"; | ||
| import Nodemailer from "nodemailer"; | ||
| import { MailtrapTransport } 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]>"; | ||
leonid-shevtsov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const transport = Nodemailer.createTransport(MailtrapTransport({ | ||
| token: TOKEN, | ||
| bulk: true | ||
| })) | ||
|
|
||
| transport.sendMail({ | ||
| text: "Welcome to Mailtrap Sending!", | ||
| to: { | ||
| address: RECIPIENT_EMAIL, | ||
| name: "John Doe" | ||
| }, | ||
| from: { | ||
| address: SENDER_EMAIL, | ||
| name: "Mailtrap Test" | ||
| }, | ||
| subject: "Hello from Mailtrap!", | ||
| html: ` | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
| </head> | ||
| <body style="font-family: sans-serif;"> | ||
| <div style="display: block; margin: auto; max-width: 600px;" class="main"> | ||
| <h1 style="font-size: 18px; font-weight: bold; margin-top: 20px">Congrats for sending test email with Mailtrap!</h1> | ||
| <p>Inspect it using the tabs you see above and learn how this email can be improved.</p> | ||
| <img alt="Inspect with Tabs" src="cid:welcome.png" style="width: 100%;"> | ||
| <p>Now send your email using our fake SMTP server and integration of your choice!</p> | ||
| <p>Good luck! Hope it works.</p> | ||
| </div> | ||
| <!-- Example of invalid for email html/css, will be detected by Mailtrap: --> | ||
| <style> | ||
| .main { background-color: white; } | ||
| a:hover { border-left-width: 1em; min-height: 2em; } | ||
| </style> | ||
| </body> | ||
| </html> | ||
| `, | ||
| attachments: [ | ||
| { | ||
| filename: "welcome.png", | ||
| content: readFileSync("./welcome.png"), | ||
| }, | ||
| ], | ||
| }).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
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
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 |
|---|---|---|
|
|
@@ -13,10 +13,9 @@ const SENDER_EMAIL = "<[email protected]>"; | |
| const RECIPIENT_EMAIL = "<[email protected]>"; | ||
|
|
||
| const transport = Nodemailer.createTransport(MailtrapTransport({ | ||
| token: TOKEN | ||
| token: TOKEN, | ||
| })) | ||
|
|
||
| // Note: 'sandbox: true' can be passed for making requests to Testing API | ||
| transport.sendMail({ | ||
| text: "Welcome to Mailtrap Sending!", | ||
| to: { | ||
|
|
||
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
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,25 @@ | ||
| 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 | ||
| */ | ||
|
|
||
| ", @see https://help.mailtrap.io/article/69-sending-domain-setup#Demo-Domain--oYOU5" | ||
|
|
||
| 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.send({ | ||
| from: { name: "Mailtrap Test", email: SENDER_EMAIL }, | ||
| to: [{ email: RECIPIENT_EMAIL }], | ||
| subject: "Hello from Mailtrap!", | ||
| text: "Welcome to Mailtrap Sending!", | ||
| }) | ||
| .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
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,62 @@ | ||
| import { readFileSync } from "fs"; | ||
| import Nodemailer from "nodemailer"; | ||
| import { MailtrapTransport } 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 transport = Nodemailer.createTransport(MailtrapTransport({ | ||
| token: TOKEN, | ||
| testInboxId: TEST_INBOX_ID, | ||
| sandbox: true | ||
narekhovhannisyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| })) | ||
|
|
||
| transport.sendMail({ | ||
| text: "Welcome to Mailtrap Sending!", | ||
| to: { | ||
| address: RECIPIENT_EMAIL, | ||
| name: "John Doe" | ||
| }, | ||
| from: { | ||
| address: SENDER_EMAIL, | ||
| name: "Mailtrap Test" | ||
| }, | ||
| subject: "Hello from Mailtrap!", | ||
| html: ` | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
| </head> | ||
| <body style="font-family: sans-serif;"> | ||
| <div style="display: block; margin: auto; max-width: 600px;" class="main"> | ||
| <h1 style="font-size: 18px; font-weight: bold; margin-top: 20px">Congrats for sending test email with Mailtrap!</h1> | ||
| <p>Inspect it using the tabs you see above and learn how this email can be improved.</p> | ||
| <img alt="Inspect with Tabs" src="cid:welcome.png" style="width: 100%;"> | ||
| <p>Now send your email using our fake SMTP server and integration of your choice!</p> | ||
| <p>Good luck! Hope it works.</p> | ||
| </div> | ||
| <!-- Example of invalid for email html/css, will be detected by Mailtrap: --> | ||
| <style> | ||
| .main { background-color: white; } | ||
| a:hover { border-left-width: 1em; min-height: 2em; } | ||
| </style> | ||
| </body> | ||
| </html> | ||
| `, | ||
| attachments: [ | ||
| { | ||
| filename: "welcome.png", | ||
| content: readFileSync("./welcome.png"), | ||
| }, | ||
| ], | ||
| }).then(console.log) | ||
| .catch(console.error) | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.