Serverless technologies are being adopted by many companies and developers are falling in love with it. This is part one of a two part article which demonstrate how easy it is to use AWS to send emails without provisioning a server.

This can be used together with your static website to create a contact form

There are a few things that you will need to get this done. In this first part, I will only focus on getting you started.

In the second part of this article we will look at how we can integrate this with your static website.

You will need the following:

  1. Login into your AWS Account
  2. Verify an email with the SES
  3. Deploy an already existing application stack

Step 1


Login to your AWS Account Console:

Login to your AWS Account Console:

Note:

Best Practice requires you to use an IAM User instead of the root user account

Select your preferred region

Step 2


Select the Simple Email Service under Services

Amazon SES Screen

Click on Email Addresses from the menu on the left

If you already have email addresses that have been verified they will appear in the list and you will see verified in green in the verification Status column.

 

Click on the Verify a New Email Address, type in the email address that you want to verify and click on the Verify this Email Address button. Make sure you have access to this email address because you will receive an email that will allow you to complete the verification

 

After clicking on the Verify this Email Address button you will receive a message like as follows:

You have successfully sent a verification email to <email@domain.com>

It may take up to an hour for the verification email to arrive in this user’s inbox. The address has been added to the list of Verified Identities with a status of “pending verification” and will be marked as “verified” when the user opens the email message and completes the verification process.

  • Check your email for a message for Amazon Web Services for the email verification.
  • Click the link supplied in the email.
  • You will be redirected to a page with a message that your email has successfully been verified.

Note

You will be in the sandbox environment as a new user. What this means is that you can only send email to the verified email address. You can however request for sending limit to be increased so you can start sending to non-verified email addresses.

  • The email address Verification Status will be changed to verified.
  • To test sending an email.
  • Click on the check box next to the email address you want to test and click the Send a Test Email button.
  • Again note you can only send an email to the same verified email because you are in the sandbox environment.
  • Fill out the subject and message body and click on Send Test Email.
  • If all goes well which it should you will receive and email from yourself in your inbox.

Done!

Step 3


Load the Lambda Service

  • Click on the Create Function button
  • There are three options for creating a Lambda function

Select the Browse serveless app repository

  • In the search box type api-lambda-send-email-ses, it will appear as the first item on the list.
  • Click on it.

Note:

This is an already built application that you can implement to send email from your forms. You don’t need to write any code.

  • Scroll down to Application settings
  • Enter the verified email in the FromEmail field and in the CorsOrigin enter ‘*’, scroll down and click the deploy button.
  • And that is it you are ready to test the application.

Step 4


Select the API Gateway Service under Services

  • You will see serverlessrepo-api-lambda-send-email-ses api created as a result of you deploying the application.
  • Click on this api.
  • Click on Stages in left menu items
  • Click POST in the green box
  • Take note of the Invoke URL, this is your endpoint to test your send email API.

Step 5


Open Postman

Enter the API url into PostMan, set the method to POST and type the following for the body

{

            “toEmails”: [“yourverified@email.com”],

            “subject” : “Test”,

            “message” : “Test Email”

}

Click Send

Status 204 - Successful

Check your inbox for the text email message

End of Part 1