Node mailer with Amazon SES

Aman Kanugo
Viithiisys
2 min readOct 30, 2017

--

Nodemailer is a module for Node.js applications to allow easy email sending. It is a single module with zero dependencies where code is easily auditable. This project aims at sending mails to multiple people with just a few lines of code. We have integrated amazon ses with our project. We have also added EJS(embedded javascript template) for design of the e-mail. In this project the data is fetched from a text-csv file in which email reciever’s data is predescribed.

Services like Amazon SES help you when you have a large traffic of email going out from your application. Using Amazon SES you can scale easily whenever you want and it can handle a large traffic. The delivery percentage is also very high.

Setting it up

The modules we need to install are:-

  1. Install Nodemailer from npm
user@user:~$ npm install nodemailer

2. File System

user@user:~$ npm install file-system

3. Comma Seperated Values(csvtojson)

 user@user:~$ npm install csvtojson

4. Amazon Simple E-mail Service(SES)

 user@user:~$ npm install node-ses

5. Embedded JavaScript (EJS)

 user@user:~$ npm install ejs 

Steps to Setup Amazon Aws Account -

Step 1. Open AWS Amazon SES To Sign in to console.

Step 2. Create An Account and add the contact-information.

Step 3. Enter Payment Information, select your plan, and verify your identity.

Step 4. Enter a group name. Type ‘ses’ into the search field to search for the access policy.Check the box next to the “AmazonSESFullAccess” policy and click “Create Group”. Click “Download .csv” to download your API keys (Access Key and Secret Access Key) in a file. Then you can click “show” to your secret access key and copy the two keys.

After, creating the access key and secret key, start by creating a client object, and then call the sendEmail method depending on your needs.

Sample Email For Single Person
Send email to Multiple people

If you want to send emails to multiple people then import a CSV file containing the reciever’s information, require all the modules and enter your access and secret keys in your project . Design your mail as your requirement in ejs format. Finally, run the following command in your terminal :

 aman@user:~$ node filename

If You have any suggestions or queries related to this project you can comment below or ping me on Linkedin.

--

--