Last active
December 25, 2019 17:37
-
-
Save zerojame/40a1b89d19968e4acd63a211a42f8e1c to your computer and use it in GitHub Desktop.
Mailtrap with nodemailer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodemailer = require("nodemailer"); | |
async function main() { | |
let transporter = nodemailer.createTransport({ | |
host: "smtp.mailtrap.io", | |
port: 2525, | |
auth: { | |
user: "", // SMTP username from mailtrap | |
pass: "", // SMTP password from mailtrap | |
} | |
}); | |
let info = await transporter.sendMail({ | |
from: '"Fred Foo 👻" <[email protected]>', | |
to: "[email protected], [email protected]", | |
subject: "Hello ✔", | |
html: "<b>Hello world?</b>", | |
attachments: [{ | |
filename: 'igg-logo.png', | |
path: 'https://www.igeargeek.com/_nuxt/img/835647d.png' | |
}] | |
}); | |
console.log("Message sent: %s", info.messageId); | |
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info)); | |
} | |
main().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment