Building a serverless contact form with AWS Lambda and AWS SES

Adnan Rahić on July 17, 2018

What if I told you it can be done with zero dependencies? Hope you're up for a challenge because that's exactly what we'll be doing. This tutori... [Read Full]
markdown guide

Hi Adnan,

Thanks for this guide. Just recently completed my portfolio and I am creating a serverless form through this guide. That said, I am lost as to where specifically should I paste this code?


Am I suppose to do it this way?

  secrets: ${file(secrets.json)} <---- delete content and replace this

  secrets: ${

Is this right?
This is my first time doing this. Never had experience with APIs.


actually you have to use ${self:custom.secrets:NODE_ENV} instead of ${self:custom.secrets.NODE_ENV}

(same for EMAIL, DOMAIN)


you dont need to replace anything,just create a file called secrets.json and paste that snippet


This is a nice writeup. But you may want to mention that this requires the pligin to be installed prior to running this code. Otherwise, it fails to create the Role for the function.


Thanks! But it doesn't need that plugin to work. You define the IAM roles in the provider section of the serverless.yml file.


Interesting. It failed to create role the first time around. But on second run, it worked fine.



I've followed the tuto up to lambda deployment but got an error during the test.

When I go to my AWS account I can't see any API Gateway nor Lambda function.

As I realize I don't understand how all of this works, I'd like to delete/uninstall what I've done.

How can I delete everything that was created following this tuto ?

Thanks in advance.


I've finally managed to make it work thanks to your lambda-mailer GitHub Repo, thank you.

But now I'd like to add recaptcha or another antispam solution to my serverless contact form.

Could you help us with that ?

Thanks in advance.


Be aware that if you set your gmail (and probably most other big providers as well like Microsoft) will not deliver your mail if it's set up like this. They will be rejected because of DMARC.


Works fine with MS O365 Exchange, but I think it's all about making sure SES is all set up correctly in your name servers with SPF and DKIM records which is what DMARC enforces. Before I even enabled SES I migrated name servers to Route53 and SES auto configured the necessary records.

I was shocked when I saw Route53 charges for DNS, as I think I've always just used a free service, but at the price of a can of soda per month I suppose it's worth it :-)


code of conduct - report abuse