Sending with Nodemailer
Integrate Mailofly into your Node.js application using the popularnodemailer library.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
nodemailer library.
npm install nodemailer
npm install -D @types/nodemailer
import nodemailer from "nodemailer";
const transporter = nodemailer.createTransport({
host: "smtp.mailofly.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "mailofly",
pass: process.env.MAILOFLY_API_KEY, // e.g. mfly_live_...
},
});
async function main() {
const info = await transporter.sendMail({
from: '"Acme" <alerts@yourcompany.com>',
to: "alex@example.com",
subject: "Hello via Nodemailer & Mailofly",
text: "Plaintext fallback message",
html: "<b>Hello from Mailofly SMTP!</b>",
});
console.log("Message sent: %s", info.messageId);
}
main().catch(console.error);