From 1e662224252eab36e26848c4b6eaf32eeaa80ca9 Mon Sep 17 00:00:00 2001 From: Harsh Shrikant Bhat <90265455+harshsbhat@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:50:31 +0530 Subject: [PATCH] docs: Added SMTP docs (#58) * Added SMTP docs * Added Nodemailer example * Change port in example --- apps/docs/get-started/smtp.mdx | 58 ++++++++++++++++++++++++++++++++++ apps/docs/introduction.mdx | 7 ++++ apps/docs/mint.json | 3 +- apps/smtp-server/src/usage.js | 8 ++--- 4 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 apps/docs/get-started/smtp.mdx diff --git a/apps/docs/get-started/smtp.mdx b/apps/docs/get-started/smtp.mdx new file mode 100644 index 0000000..572a9d9 --- /dev/null +++ b/apps/docs/get-started/smtp.mdx @@ -0,0 +1,58 @@ +--- +title: SMTP support +description: "A guide to integrate Unsend with SMTP" +icon: envelope +--- + +## Prerequisites + +You will need an API key and a verified domain to get the most out of this guide: + +- [API Key](https://app.unsend.dev/dev-settings/api-keys) +- [Verified Domain](https://app.unsend.dev/domains) + +## SMTP credentials + +To set up your SMTP integration, you'll need to provide the following credentials: + +- **Host:** ```smtp.unsend.dev``` +- **Port:** ```465```, ```587```, ```2465```, or ```2587``` +- **Username:** ```unsend``` +- **Password:** ```YOUR-API-KEY``` + +## Example with Nodemailer + +Following example with Nodemailer shows how you can send mails with SMTP support from Unsend and Nodemailer. + +```javascript +const nodemailer = require("nodemailer"); + +const transporter = nodemailer.createTransport({ + host: "smtp.unsend.dev", + port: 465, + secure: false, + auth: { + user: "unsend", + pass: "us_123", + }, + tls: { + rejectUnauthorized: false, + }, +}); + +const mailOptions = { + to: "sender@example.com", + from: "hello@example.com", + subject: "Testing SMTP", + html: "THIS IS USING SMTP,
Unsend is the best open source sending platform
check out unsend.dev",
+ text: "hello,\n\nUnsend is the best open source sending platform",
+};
+
+transporter.sendMail(mailOptions, (error, info) => {
+ if (error) {
+ console.error("Error sending email:", error);
+ } else {
+ console.log("Email sent successfully:", info.response);
+ }
+});
+```
\ No newline at end of file
diff --git a/apps/docs/introduction.mdx b/apps/docs/introduction.mdx
index 4d11850..cb3fe60 100644
--- a/apps/docs/introduction.mdx
+++ b/apps/docs/introduction.mdx
@@ -38,4 +38,11 @@ Quicklinks to set up your account and get started
>
Learn how to use our API to send emails programmatically.
+
Unsend is the best open source sending platform
check out unsend.dev", text: "hello,\n\nUnsend is the best open source sending platform",