Creating an SMTP server
SMTP 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 in 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-smtp $ touch server.js
As we’ll be using the third-party smtp-server
module from npm
, 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 a module where the project name is the same as the module. If we had named our directory smtp-server
, our package.json
name would have also been set to smtp-server
, and we would not...