Skip to content

Commit

Permalink
Merge pull request #38 from railsware/restructure-samples
Browse files Browse the repository at this point in the history
Restructure samples, add template sample for testing
  • Loading branch information
narekhovhannisyan authored May 19, 2024
2 parents b049c3e + d6fc4a5 commit cf58f3f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ Refer to the [`examples`](examples) folder for the source code of this and other
- [Remove account access](examples/general/accounts.ts)
- [Permissions](examples/general/permissions.ts)

### Sending API

- [Advanced](examples/sending/everything.ts)
- [Minimal](examples/sending/minimal.ts)
- [Send email using template](examples/sending/template.ts)
- [Nodemailer transport](examples/sending/transport.ts)

### Email testing API

- [Attachments](examples/testing/attachments.ts)
- [Inboxes](examples/testing/inboxes.ts)
- [Messages](examples/testing/messages.ts)
- [Projects](examples/testing/projects.ts)
- [Send mail using template](examples/testing/template.ts)

### Nodemailer Transport

Expand Down
2 changes: 1 addition & 1 deletion examples/general/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ const client = new MailtrapClient({ token: TOKEN, testInboxId: TEST_INBOX_ID, ac

const accountsClient = client.general.accounts

accountsClient.getAllAcounts()
accountsClient.getAllAccounts()
.then(console.log)
.catch(console.error)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions examples/testing/template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MailtrapClient } from "../../src"

/**
* For this example to work, you need to set up a sending domain,
* and obtain a token that is authorized to send from the domain.
* @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.testing.send({
from: { name: "Mailtrap Test", email: SENDER_EMAIL },
to: [{ email: RECIPIENT_EMAIL }],
template_uuid: "813e39db-c74a-4830-b037-0e6ba8b1fe88",
template_variables: {
user_name: "John Doe",
}
})
.then(console.log)
.catch(console.error);
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3597,9 +3597,9 @@ node-releases@^2.0.6:
integrity sha512-EJ3rzxL9pTWPjk5arA0s0dgXpnyiAbJDE6wHT62g7VsgrgQgmmZ+Ru++M1BFofncWja+Pnn3rEr3fieRySAdKQ==

nodemailer@^6.9.4:
version "6.9.9"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.9.tgz#4549bfbf710cc6addec5064dd0f19874d24248d9"
integrity sha512-dexTll8zqQoVJEZPwQAKzxxtFn0qTnjdQTchoU6Re9BUUGBJiOy3YMn/0ShTW6J5M0dfQ1NeDeRTTl4oIWgQMA==
version "6.9.7"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.7.tgz#ec2f488f62ba1558e7b19239b62778df4a5c4397"
integrity sha512-rUtR77ksqex/eZRLmQ21LKVH5nAAsVicAtAYudK7JgwenEDZ0UIQ1adUGqErz7sMkWYxWTTU1aeP2Jga6WQyJw==

normalize-path@^3.0.0:
version "3.0.0"
Expand Down

0 comments on commit cf58f3f

Please sign in to comment.