Nodemailer
Nodemailer is a module that enables to send emails using SMTP protocol

Official Websitehttps://nodemailer.com
Documentationhttps://nodemailer.com/usage/
NodeJS packagehttps://www.npmjs.com/package/nodemailer
Version6.8.0
Source Codehttps://github.com/nodemailer/nodemailer
Tagsemail, smtp
Network Connection needs
This integration needs network access to the server where the service is running.
See the Network access page for details about how to achieve that.
Credential configuration
To configure this credential you need the host
, port
, username
and password
to connect to the SMTP server.
Optionally you can set any of the extra config params you can see here for SMTP transport protocol. You also may look to other transport protocols if you need.
Here you have an example of a filled credential configuration form in YepCode:

Nodemailer snippets available in editor
note
The title is the triggering text for YepCode to autocomplete the script
Integration
New integration from credential
const nodemailerTransport = yepcode.integration.nodemailer('credential-slug')
New integration from plain authentication data
const nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
const nodemailerTransport = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false,
connectionTimeout: 100,
auth: {
user: "user",
pass: "password",
},
});
Verify SMTP connection configuration
Verify SMTP connection configuration (async/await)
// verify connection configuration
try {
const verified = await nodemailerTransport.verify()
console.log("Server is ready to take our messages");
} catch (error) {
console.error(error);
throw error;
}
Verify SMTP connection configuration (Promise)
// verify connection configuration
nodemailerTransport.verify().then(() => {
console.log("Server is ready to take our messages");
}).catch((error) => {
console.error(error);
throw error;
});
Verify SMTP connection configuration (callback)
// verify connection configuration
nodemailerTransport.verify(function(error, success) {
if (error) {
console.error(error);
} else {
console.log("Server is ready to take our messages");
}
});
Send mail
Send mail (async/await)
try {
const info = await nodemailerTransport.sendMail({
from: '"Fred Foo 👻" <foo@example.com>', // sender address
to: "bar@example.com, baz@example.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
})
console.log("Message sent: " + info.messageId);
console.log("Preview URL: " + nodemailer.getTestMessageUrl(info));
} catch (error) {
console.error(error);
throw error;
}
Send mail (Promise)
nodemailerTransport.sendMail({
from: '"Fred Foo 👻" <foo@example.com>', // sender address
to: "bar@example.com, baz@example.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
}).then((info) => {
console.log("Message sent: " + info.messageId);
console.log("Preview URL: " + nodemailer.getTestMessageUrl(info));
}).catch((error) => {
console.error(error);
throw error;
});
Send mail (callback)
nodemailerTransport.sendMail({
from: '"Fred Foo 👻" <foo@example.com>', // sender address
to: "bar@example.com, baz@example.com", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>", // html body
}, (error, info) => {
if (error) {
console.error(error);
} else {
console.log("Message sent: " + info.messageId);
console.log("Preview URL: " nodemailer.getTestMessageUrl(info));
}
});