docs: Added SMTP docs (#58)
* Added SMTP docs * Added Nodemailer example * Change port in example
This commit is contained in:
committed by
GitHub
parent
002af10f84
commit
1e66222425
58
apps/docs/get-started/smtp.mdx
Normal file
58
apps/docs/get-started/smtp.mdx
Normal file
@@ -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: "<strong>THIS IS USING SMTP,</strong><p>Unsend is the best open source sending platform<p><p>check out <a href='https://unsend.dev'>unsend.dev</a>",
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
@@ -38,4 +38,11 @@ Quicklinks to set up your account and get started
|
|||||||
>
|
>
|
||||||
Learn how to use our API to send emails programmatically.
|
Learn how to use our API to send emails programmatically.
|
||||||
</Card>
|
</Card>
|
||||||
|
<Card
|
||||||
|
title="SMTP support"
|
||||||
|
icon="envelope"
|
||||||
|
href="/get-started/smtp"
|
||||||
|
>
|
||||||
|
Send emails with SMTP server instead of REST API.
|
||||||
|
</Card>
|
||||||
</CardGroup>
|
</CardGroup>
|
||||||
|
@@ -50,7 +50,8 @@
|
|||||||
"introduction",
|
"introduction",
|
||||||
"get-started/nodejs",
|
"get-started/nodejs",
|
||||||
"get-started/local",
|
"get-started/local",
|
||||||
"get-started/self-hosting"
|
"get-started/self-hosting",
|
||||||
|
"get-started/smtp"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
const transporter = nodemailer.createTransport({
|
const transporter = nodemailer.createTransport({
|
||||||
host: "localhost",
|
host: "smtp.unsend.dev",
|
||||||
port: 2587,
|
port: 2587,
|
||||||
secure: false,
|
secure: false,
|
||||||
auth: {
|
auth: {
|
||||||
user: "unsend",
|
user: "unsend",
|
||||||
pass: "us_38de56vwa7_cc90a91b01a402de0c15516b3554adc1",
|
pass: "us_123",
|
||||||
},
|
},
|
||||||
tls: {
|
tls: {
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
@@ -14,8 +14,8 @@ const transporter = nodemailer.createTransport({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const mailOptions = {
|
const mailOptions = {
|
||||||
to: "harsh121102@gmail.com",
|
to: "sender@example.com",
|
||||||
from: "hello@support.harshbhat.me",
|
from: "hello@example.com",
|
||||||
subject: "Testing SMTP",
|
subject: "Testing SMTP",
|
||||||
html: "<strong>THIS IS USING SMTP,</strong><p>Unsend is the best open source sending platform<p><p>check out <a href='https://unsend.dev'>unsend.dev</a>",
|
html: "<strong>THIS IS USING SMTP,</strong><p>Unsend is the best open source sending platform<p><p>check out <a href='https://unsend.dev'>unsend.dev</a>",
|
||||||
text: "hello,\n\nUnsend is the best open source sending platform",
|
text: "hello,\n\nUnsend is the best open source sending platform",
|
||||||
|
Reference in New Issue
Block a user