Sending Emails using AWS, SES and SmartFlows

To send email from Lambda using Amazon SES, you need the following:

  • AWS Identity and Access Management (IAM) permissions for Lambda to execute the API call.
  • A verified Amazon SES identity (domain or email address).
  • A Lambda function with logic for sending email via Amazon SES.

Note: The example Lambda function code in Node.js is provided as-is. Adapt the example to your use case or design your own in your preferred programming language.

Create an AWS Lambda Function

  1. Open the AWS Lambda Console.
  2. Choose Create a function.
  3. For Function name, enter my-email-function.
  4. Choose Create function.
  5. Paste the following into the code editor:
var aws = require('aws-sdk');
var ses = new aws.SES({region: 'us-east-1'});
exports.handler = (event, context, callback) => {
var params = {
Destination: {
ToAddresses: [event.toEmailAddress]
Message: {
Body: {
Text: { Data: event.body}
Subject: { Data: event.subject}
Source: event.fromEmailAddress
ses.sendEmail(params, function (err, data) {
callback(null, {err: err, data: data});
if (err) {

Add an API Trigger

  1. Select Add Trigger.

  1. Select API Gateway from the dropdown.
  2. Select Create a New API from the API dropdown.
  3. Select the REST API template.
  4. Click Add.

Create an IAM Policy and Execution Role

  1. Open the IAM Management Console.
  2. In the left hand nav window, select Policies.
  3. Click Create Policy.
  4. Select the JSON tab.
  5. Paste this JSON policy document into the policy editor:
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
"Resource": "*"
  1. Click Review Policy.
  2. For policy name, enter my-email-policy, and click Create Policy.
  3. In the left hand nav window, select Roles.
  4. Click Create Role.
  5. Select AWS Services for Type of Trusted Entity and Lambda for Use Case. Click Next: Permissions.
  6. Select my-email-policy, and click Next: Tags.
  7. Add any desired tags and click Next: Review.
  8. Provide your role a name and click Create Role.
  9. Navigate to your lambda function.
  10. Under Execution Role, select Use an existing role and the role you just created.

Update Your SmartFlow

  1. Add an External Web Call action to your flow.
  2. Configure the action as follows:


URL OF SERVICE: URL created in API Gateway

CONTENT-TYPE: application/json


"toEmailAddress": "Enter the email address of the recipient",
"fromEmailAddress": " A verified Amazon SES identity (domain or email address).",
"subject": "My test email subject",
"text": "Hello from SmartFlows"

You can now activate your flow and an email should be generated.