Skip to content

ceccode/serverless-contact-service

Repository files navigation

Serverless contact service

Build Status Known Vulnerabilities https://david-dm.org/ceccode/serverless-contact-service.svg

API Gateway + AWS Lambda + AWS SES

The email function use the AWS SDK for Node.js to send an email using AWS Simple Email Service.

Usefull for:

  • Marketing websites
  • Product landing pages
  • Micro-sites
  • Team homepages

Install

  1. Setup your AWS Credentials
  2. Install Serverless.js
npm install -g serverless
  1. Clone the project:
git clone git@github.com:ceccode/serverless-contact-service.git
  1. Install dependencies
npm install

Configuration

  1. In your serverless.yml file set environment var:
  environment:
    EMAIL_SENDER: 'you-sender-address'
    EMAIL_RECEIVER: 'you-receiver-address'
    EMAIL_OBJECT: 'Referral Form'

This project use Amazon SES to send emails. For testing, it restricts the email addresses that can “send” and “receive” messages to ones that have been “verified”. Go to the SES page of the Console, choose Email Addresses > Verify New Email Address.

  1. Ad an usage plan to your api-key, see how here

Find the api-key name in your serverless.yml file:

  apiKeys:
    - contack-key   

Deploy

npm run deploy

Use

[POST] /contact

Headers

{
	"Content-Type": "application/json",
    "x-api-key": "spnbH7eO7Rgj1Kv6tJ7v9jKwvY6sPyL27eV8nYqb",
}

Body:

{
	"name": "Mario Rossi",
    "email": "mario.rossi@example.it",
	"message": "My message"
}

Test

Run all tests

npm test

Coverage

npm run test-travis

License

MIT license

About

Serverless contact service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published