Files
2026-11-10 22:41:18 -06:00

36 lines
1.0 KiB
JavaScript

import nodemailer from "nodemailer";
// Create a transporter using SMTP
const transporter = nodemailer.createTransport({
host: "us1.smtp.bird.com",
port: 587,
secure: false, // use STARTTLS (upgrade connection to TLS after connecting)
auth: {
user: "bird",
pass: "", // TODO: use environment variables
},
});
try {
await transporter.verify();
console.log("Server is ready to take our messages");
} catch (err) {
console.error("Verification failed:", err);
}
try {
const info = await transporter.sendMail({
from: '"CPC Security" <[email protected]>', // sender address
to: "[email protected]", // list of recipients
subject: "Hello", // subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // HTML body
});
console.log("Message sent: %s", info.messageId);
// Preview URL is only available when using an Ethereal test account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
} catch (err) {
console.error("Error while sending mail:", err);
}