@ribban/unsend-nodemailer
v2.0.4
Published
Transport for Nodemailer to send mails using the Unsend API.
Readme
Unsend Nodemailer
NPM package allowing you to send emails easily with the Unsend API.
How to get started
1. Install the package
npm install @ribban/unsend-nodemailerUsage
Create Nodemailer Transport
import { UnsendTransport } from '@ribban/unsend-nodemailer';
import { createTransport } from 'nodemailer';
const mailer = createTransport(
UnsendTransport.makeTransport({
apiKey: YOUR_UNSEND_API_KEY
})
);Custom API Endpoint (Optional)
If you need to use a custom Unsend API endpoint (e.g., self-hosted instance):
const mailer = createTransport(
UnsendTransport.makeTransport({
apiKey: YOUR_UNSEND_API_KEY,
apiUrl: 'https://your-custom-endpoint.com' // Default is 'https://api.unsend.dev'
})
);Send an Email
mailer.sendMail({
from: '[email protected]',
to: '[email protected]',
subject: 'This is a example email!',
html: '<h1>Enter your HTML content here!</h1>',
});Specifying Sender Name
You can include a display name with the email address:
mailer.sendMail({
from: 'RIBBAN <[email protected]>',
to: 'Recipient Name <[email protected]>',
subject: 'Email with sender name',
html: '<p>This email has a display name!</p>',
});