Published April 17, 2022 by

Mail Server Using Serverless Framework AWS [Lambda + SES +IAM]

 Mail Server Using Serverless Framework On AWS [Lambda + SES +IAM]





In this article, the implementation of the MAIL Server by using the serverless Framework without doing the Changes in the AWS Account is Demonstrated Step by Step.

MAIL Server is Sending and receiving the Mail with the AWS →SES Services. as without the use of Gmail service, we can send the Mail from source to destination.

How to Deploy the Integrated Services on AWS using Serverless Framework

Pre-Requisites

  1. AWS Account

2. Nodejs

3. Programming Language (python)

4. Serverless framework

5. To Demonstrate, need 2 unique Gmail accounts.

To Begin,

Step 1:

Serverless Setup with AWS

  1. For setting up a connection with AWS, first, we need to install Serverless using CLI via NPM

#npm -g install serverless

2. Authenticating Serverless framework to Use Our AWS Account

#serverless config credentials[space] — — provider aws [space] — — key [Key in IAM] — — secret[Key in IAM] — — overwrite

3. Create a new serverless project & Select Language

#serverless

# SELECT LANGUAGE

4. Move into the newly created directory

#cd your-service-name

6. To Deploy the Serverless framework

#serverless deploy

Step 2:

Create an account in AWS using the IAM service with Full Administration Access to set up the credential to login via serverless.

Follow the Below Steps…

For creating an account using IAM in AWS

  • Go to the IAM service
  • Select users
  • Create new user
  • Give the user a name and Select the Access key
  • Give Access Power i.e, Attach Existing Policy: Administration Acess
  • Review and click on create user






Step 3:

Amazon Simple Email Service

We use the SES service for sending and receiving emails.
ADD Gmail account from which you want to send and receive the mails

steps for adding Gmail to the SES service

  • Go to SES service in AWS
  • Click on Create Identity
  • Select Email Address and Type your Email Address
  • And click on Create Identity
  • Verify your email to use it.

You need to add a minimum of two email addresses for sending and receiving mails









→ Authentication Mail Has been sent to Mail Click and Do verify.

AWS SES

Step 4:

Starting Serverless

#Serverless

Follow the below cmd to create with Serverless(SLS)

After Successfully Creating the Serverless project, Go inside the folder and edit both the handler.js and serverless.yml files.

As the actual Implementation of the Code is present in the Github

#notepad handler.js
#notepad serverless.yml

Copy Paste the code provided from the GitHub Repository.

https://github.com/Prashanth102000/SES_Mail_Server

After Editing the codes with the same folder files

Finally, you have to deploy it by the following command

#serverless deploy


CLI

Step 5 :

To Sending, mail will be using Postman Software

https://www.postman.com/downloads/

As it is a POST method, we can create a UI to post or we can POST using the Postman tool,

Open up the Postman tool → Choose the POST method → Paste the Link generated by the Serverless in the given address bar → Select RAW → Apply the Below Code with Your Created 2 unique Gmail → Click on Send



Email Sent successfully

THANK YOU