SMTP
Nodemailer (SMTP)
Send your first email from Node.js with Nodemailer over the MailBlastr SMTP relay.
If you already use Nodemailer in your Node.js app, you can send through MailBlastr without touching the HTTP API. Point the transport at the MailBlastr SMTP relay and authenticate with your API key. Emails sent over SMTP show up in your dashboard and event log just like API sends.
Prerequisites
- A MailBlastr API key.
- A verified domain to send from.
1. Install
Add the nodemailer package to your project.
npm install nodemailer2. SMTP credentials
Configure the transport with the following credentials:
Hoststringoptionalsmtp.mailblastr.com
Portnumberoptional465 (implicit TLS) or 587 (STARTTLS).
Usernamestringoptionalmailblastr
PasswordstringoptionalYour API key, e.g. mb_xxxxxxxxx.
3. Send email using SMTP
Create a transport with these credentials, then send. The from address must be on a verified domain.
index.ts
import nodemailer from 'nodemailer';
async function main() {
const transporter = nodemailer.createTransport({
host: 'smtp.mailblastr.com',
secure: true,
port: 465,
auth: {
user: 'mailblastr',
pass: 'mb_xxxxxxxxx',
},
});
const info = await transporter.sendMail({
from: 'Acme <onboarding@yourdomain.com>',
to: 'delivered@example.com',
subject: 'Hello World',
html: '<strong>It works!</strong>',
});
console.log('Message sent: %s', info.messageId);
}
main().catch(console.error);Prefer the HTTP API for richer control (idempotency replay, scheduling, attachments by URL). SMTP is best when you already have a Nodemailer setup. See Send an email for the full HTTP body.