Simple Email Service (SES)

Configuration

Configuration sets

  1. Access Configuration sets

  2. Click the Create set button

    • Configuration set name: credere

  3. Click the Event destinations tab

  4. Click the Add destination button

    See also

    CloudWatch

    Select event types
    • Sending and delivery: Check all

    Specify destination
    • Destination type: Check “Amazon CloudWatch”

    • Name: crede-metrics-to-cloudwatch (sic)

    • Value source: Select “Message tag”

    • Dimension name: ses:configuration-set

    • Default value: crede-metrics-to-cloudwatch (sic)

    Select event types
    • Sending and delivery: Check:
      • Rendering failures

      • Rejects

      • Delivery delays

    Specify destination
    • Destination type: Check “Amazon SNS”

    • Name: credere-noreply-open-contracting-org

    • SNS topic: credere-noreply-open-contracting-org

Identities

  1. Verify an email address (credere@noreply.open-contracting.org)

    Authentication
    Notifications
    Configuration set
    • Assign credere as the default configuration set

Email templates

One-time setup

  1. Install the AWS CLI

  2. Run the configure command to set the administrative user’s credentials and region:

    aws configure --profile credere-admin
    

The files matching the pattern email_templates/aws_* are used as email templates. They serve as layouts for all messages, including styles, a header, a footer, and a {{CONTENT}} tag.

  • aws_main.html

  • aws_main_es.html

When deploying for the first time, and after changing these files:

  1. Create the input JSON for each template:

    python -m app dev cli-input-json credere-main-en email_templates/aws_main.html > credere-main-en.json
    python -m app dev cli-input-json credere-main-es email_templates/aws_main_es.html > credere-main-es.json
    
  2. Run the ses create-template command with the administrative user:

    aws ses create-template --profile credere-admin --cli-input-json file://credere-main-en.json
    aws ses create-template --profile credere-admin --cli-input-json file://credere-main-es.json
    

Tasks

Get an email template

Use the CLI (the console only lists templates):

aws ses get-template --profile credere-admin --template-name credere-main-es

Preview a templated email

  1. Create an input JSON file, using the skeleton from:

    aws ses test-render-template --generate-cli-skeleton
    

    For example:

    {
      "TemplateName": "credere-main-es",
      "TemplateData": "{\"SUBJECT\":\"my subject\",\"CONTENT\":\"my content\"}"
    }
    
  2. Run the ses test-render-template command, for example:

    aws ses test-render-template --profile credere-admin --cli-input-json file://test.json
    

Send a templated email

  1. Create an input JSON file, using the skeleton from:

    aws ses send-templated-email --generate-cli-skeleton
    

    For example:

    {
      "Source": "Credere_Test <credere@noreply.open-contracting.org>",
      "Destination": {
        "ToAddresses": ["me@open-contracting.org"]
      },
      "ReplyToAddresses": ["test@open-contracting.org"],
      "Template": "credere-main-es",
      "TemplateData": "{\"SUBJECT\":\"my subject\",\"CONTENT\":\"my content\"}"
    }
    
  2. Run the ses send-templated-email command, example:

    aws ses send-templated-email --profile credere-admin --cli-input-json file://test.json