Creating an SMTP server
We don't have to rely on a third-party SMTP server; we can create our own!
In this recipe, we'll create our own internal SMTP server (just like the first SMTP servers) using the third-party simplesmtp
module, which is an underlying library of the nodemailer
module from the first recipe of this chapter, Sending an e-mail. For information on converting an internal SMTP server to an externally exposed MX record server, see the There's more... section at the end of this recipe.
Getting ready
Let's create a file and call it server.js
, then make a new folder called mailboxes
containing three subfolders: bob
, bib
, and susie
. We'll also want to have our mailout.js
file from the first recipe in hand.
We'll also need the simplesmtp
and nodemailer
modules. We'll install them with the help of the following command:
npm install simplesmtp nodemailer
How to do it...
First, we'll set up some initial variables as follows:
var simplesmtp = require('simplesmtp'); var fs = require('fs');...