Using Nodemailer
Learn how to send transactional emails using Plunk with Nodemailer
Nodemailer is a popular Node.js module which allows you to easily send emails. In this guide, you’ll learn how to set it up with Plunk’s SMTP settings.
Prerequisites
Before we begin, we’ll need to install nodemailer
, and store sensitive values inside a .env
file.
Install Nodemailer
Install Nodemailer types (Optional)
If you’re using TypeScript in your project, make sure to download @types/nodemailer
as well:
Setup environment varaibles
It is best practise to store sensitive values inside an .env
file, add the following values to your env file:
Sending Transactional emails
Now our project is setup, we can send transactional emails using Nodemailer. First, we need to setup the transporter
which holds the connection information and decide what secure method to use:
Using STARTTLS
To use STARTTLS, set your port to 587
and set secure
to false:
Using SSL
To use SSL, set your port to 465
and set secure
to true:
Sending mail!
Now that the transporter
has been initalised, we can send some mail!