Sending an automated email using your own SMTP server
SMTP stands for Simple Mail Transfer Protocol and is a protocol for sending emails. In this recipe, we will be setting up an SMTP server using a third-party npm
module named smtp-server
.
You probably receive several automated emails per day to your inbox. In the There's more… section, we're going to learn how we can send an email via Node.js to the SMTP server we created in the recipe.
Getting ready
First, let's create a directory named server-smtp
and a file named server.js
:
$ mkdir server-smtp $ cd server-smpt $ touch server.js
As we'll be using the third-party npm smtp-server
module, we will need to initialize our project:
$ npm init –yes
Important note
Note that we could not name our directory for this recipe smtp-server
as npm refuses to allow you to install an npm module where the project name is the same as the module. If we had named our directory smtp-server
, our...