Repository navigation
Add Sandbox and Domain names; deprecate Testing, Inbox and SendingDomain #180
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c151db3
Add Sandbox and Domain names and deprecate the old ones
Rabsztok c769b14
Treat null IDs as unset and fix the sandbox and domains examples
Rabsztok a3d9199
Pass a numeric accountId in the sandbox examples
Rabsztok 959cea0
Drop unimportable types from the README and pass numeric sandbox IDs
Rabsztok 0b3e730
Merge remote-tracking branch 'origin/main' into sdks-cli-and-mcp-adop…
izikaj 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
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,57 @@ | ||
| import { MailtrapClient } from "mailtrap"; | ||
|
|
||
| const TOKEN = "<YOUR-TOKEN-HERE>"; | ||
| const ACCOUNT_ID = "<YOUR-ACCOUNT-ID-HERE>"; | ||
|
|
||
| const client = new MailtrapClient({ | ||
| token: TOKEN, | ||
| accountId: Number(ACCOUNT_ID), | ||
| }); | ||
|
|
||
| async function domainsFlow() { | ||
| try { | ||
| // Get all domains | ||
| const all = await client.domains.getList(); | ||
| console.log("All domains:", JSON.stringify(all, null, 2)); | ||
|
|
||
| if (all.data && all.data.length > 0) { | ||
| // Get a specific domain | ||
| const one = await client.domains.get(all.data[0].id); | ||
| console.log("One domain:", JSON.stringify(one, null, 2)); | ||
|
|
||
| // Send setup instructions | ||
| await client.domains.sendSetupInstructions( | ||
| all.data[0].id, | ||
| "admin@example.com" | ||
| ); | ||
| console.log("Setup instructions sent"); | ||
| } else { | ||
| console.log("No domains found for this account."); | ||
| } | ||
|
|
||
| // Create a new domain | ||
| const created = await client.domains.create({ | ||
| domain_name: "test-domain-" + Date.now() + ".com", | ||
| }); | ||
| console.log("Created domain:", JSON.stringify(created, null, 2)); | ||
|
|
||
| // Update the settings of the created domain | ||
| const updated = await client.domains.update(created.id, { | ||
| open_tracking_enabled: true, | ||
| click_tracking_enabled: true, | ||
| tracking_opt_out_enabled: true, | ||
| auto_unsubscribe_link_enabled: false, | ||
| inbound_enabled: false, | ||
| }); | ||
| console.log("Updated domain:", JSON.stringify(updated, null, 2)); | ||
|
|
||
| // Delete the created domain | ||
| await client.domains.delete(created.id); | ||
| console.log("Domain deleted"); | ||
|
|
||
| } catch (error) { | ||
| console.error("Error in domainsFlow:", error instanceof Error ? error.message : String(error)); | ||
| } | ||
| } | ||
|
|
||
| domainsFlow(); |
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
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,32 @@ | ||
| import { MailtrapClient } from "mailtrap" | ||
|
|
||
| const TOKEN = "<YOUR-TOKEN-HERE>"; | ||
| const ACCOUNT_ID = "<YOUR-ACCOUNT-ID-HERE>" | ||
|
|
||
| const client = new MailtrapClient({ token: TOKEN, accountId: Number(ACCOUNT_ID) }); | ||
|
|
||
| const sandboxesClient = client.sandbox.sandboxes | ||
| const messagesClient = client.sandbox.messages | ||
| const attachmentsClient = client.sandbox.attachments | ||
|
|
||
| sandboxesClient.getList() | ||
| .then(async (sandboxes) => { | ||
| if (sandboxes && sandboxes.length > 0) { | ||
| const firstSandboxId = sandboxes[0].id | ||
|
|
||
| const messages = await messagesClient.get(firstSandboxId) | ||
|
|
||
| if (messages && messages.length > 0) { | ||
| const firstMessageId = messages[0].id | ||
|
|
||
| const attachments = await attachmentsClient.getList(firstSandboxId, firstMessageId) | ||
|
|
||
| if (attachments && attachments.length > 0) { | ||
| const firstAttachment = attachments[0].id | ||
| const attachmentData = await attachmentsClient.get(firstSandboxId, firstMessageId, firstAttachment) | ||
|
|
||
| console.log(attachmentData) | ||
| } | ||
| } | ||
| } | ||
| }) |
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" | ||
|
|
||
| const TOKEN = "<YOUR-TOKEN-HERE>"; | ||
| const ACCOUNT_ID = "<YOUR-ACCOUNT-ID-HERE>" | ||
|
|
||
| const client = new MailtrapClient({ token: TOKEN, accountId: Number(ACCOUNT_ID) }); | ||
|
|
||
| const sandboxesClient = client.sandbox.sandboxes | ||
| const messagesClient = client.sandbox.messages | ||
|
|
||
| sandboxesClient.getList() | ||
| .then(async (sandboxes) => { | ||
| if (sandboxes && sandboxes.length > 0) { | ||
| const firstSandboxId = sandboxes[0].id | ||
|
|
||
| const messages = await messagesClient.get(firstSandboxId) | ||
|
|
||
| if (messages && messages.length > 0) { | ||
| const firstMessageId = messages[0].id | ||
|
|
||
| await messagesClient.getHtmlAnalysis(firstSandboxId, firstMessageId) | ||
| await messagesClient.getHtmlMessage(firstSandboxId, firstMessageId) | ||
| await messagesClient.getTextMessage(firstSandboxId, firstMessageId) | ||
| await messagesClient.getMailHeaders(firstSandboxId, firstMessageId) | ||
| await messagesClient.getMessageAsEml(firstSandboxId, firstMessageId) | ||
| await messagesClient.getMessageHtmlSource(firstSandboxId, firstMessageId) | ||
| await messagesClient.getRawMessage(firstSandboxId, firstMessageId) | ||
| await messagesClient.getSpamScore(firstSandboxId, firstMessageId) | ||
| await messagesClient.showEmailMessage(firstSandboxId, firstMessageId) | ||
| await messagesClient.updateMessage(firstSandboxId, firstMessageId, { | ||
| isRead: false | ||
| }) | ||
| await messagesClient.forward(firstSandboxId, firstMessageId, 'mock@mail.com') | ||
| const response = await messagesClient.deleteMessage(firstSandboxId, firstMessageId) | ||
|
|
||
| console.log(response) | ||
| } | ||
| } | ||
| }) |
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,32 @@ | ||
| import { MailtrapClient } from "mailtrap" | ||
|
|
||
| const TOKEN = "<YOUR-TOKEN-HERE>"; | ||
| const ACCOUNT_ID = "<YOUR-ACCOUNT-ID-HERE>" | ||
|
|
||
| const client = new MailtrapClient({ token: TOKEN, accountId: Number(ACCOUNT_ID) }); | ||
|
|
||
| const projectsClient = client.sandbox.projects | ||
| const sandboxesClient = client.sandbox.sandboxes | ||
|
|
||
| projectsClient.getList() | ||
| .then(async (projects) => { | ||
| if (projects && projects.length > 0) { | ||
| const firstProjectId = projects[0].id | ||
|
|
||
| // Work on the sandbox created here, so the account's existing sandboxes stay untouched. | ||
| const { id: sandboxId } = await sandboxesClient.create(firstProjectId, 'test-sandbox') | ||
|
|
||
| const sandboxes = await sandboxesClient.getList() | ||
| console.log(sandboxes) | ||
|
|
||
| const sandboxAttributes = await sandboxesClient.getSandboxAttributes(sandboxId) | ||
| await sandboxesClient.updateSandbox(sandboxId, {name: 'mock-name', emailUsername: 'mocker'}) | ||
| await sandboxesClient.cleanSandbox(sandboxId) | ||
| await sandboxesClient.markAsRead(sandboxId) | ||
| await sandboxesClient.resetCredentials(sandboxId) | ||
| await sandboxesClient.enableEmailAddress(sandboxId) | ||
| const response = await sandboxesClient.resetEmailAddress(sandboxId) | ||
|
|
||
| console.log(response) | ||
| } | ||
| }) |
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
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.