Simple email sender running on Lambda
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Simple email sender running on Lambda. It sends emails via AWS SES. It comes in handy when you would add a contact form to your static website.



Init your project

git clone
cd send-email-lambda
apex init
> Project nane: send-email

Edit your project.json file based on project.json.example like:

  "name": "send-email",
  "description": "Simple email transmitter",
  "memory": 128,
  "timeout": 5,
  "environment": {},
  "runtime": "nodejs6.10",
  "role": "<YOUR_IAM_ROLE>"


Edit functions/submit/function.json as you like:

  "environment": {
    "SES_REGION": "us-west-2",
    "FROM_NAME": "Craftzdog Contact Form",
  • SES_REGION: The AWS region for the SES
  • FROM_NAME: Sender name like "Contact Form"
  • FROM_EMAIL: The email address you would receive from. e.g.,
  • TO_EMAIL: Your personal email address to receive emails.

Add a permission to send emails to the IAM role

Add following policy to your lambda's IAM role (ex. send-email_lambda_function) that allows the lambda function to use SES.sendEmail with policy name send-email_submit:

    "Version": "2012-10-17",
    "Statement": [
            "Sid": "Stmt1504526549000",
            "Effect": "Allow",
            "Action": [
            "Resource": [

Deploy and test sending emails

At the project top directory:

apex deploy

You can run the lambda function manually with below command:

echo -n '{ "subject": "hello", "body": "world" }' | apex invoke submit

And you will get an email to the configured address.

Publish on the Web

API Gateway

Configure your API Gateway like this:

API Gateway

And deploy the API.

Swagger definitions

See the swagger YAML file as an example.



It accepts JSON data with 2 fields:

  • subject: The message subject
  • body: The message body


MIT, Copyright 2017 by Takuya Matsuyama <>