Sign inSign up

clevyr/ses-email-service

By clevyr

Updated almost 7 years ago

Image
0

1.2K

clevyr/ses-email-service repository overview

SES Email Service

CircleCI

This service is used to help with clients who need a large amount of emails sent via SES and need to deal with rate limiting.

There are two services within this repo, the SES Email Service to be run as a Docker container, and the Email Blacklist service that runs in Lambda and listens to SNS for email bounce or complaint notifications, and adds them to a global blacklist.

The blacklist lambda will update automatically with a push to the master branch.

The email service docker will update :latest on a push to the master branch, and will update version :x.x.x if you tag a commit with a semver version tag, for example, Docker tag :1.0.0 points to Git tag 1.0.0.

Service Environment Variables

Environment VariableDetailsExample
USE_BLACKLISTWhether to use the Clevyr email recipient blacklisttrue
AWS_ACCESS_KEY_IDSpecifies an AWS access key associated with an IAM user or role, used to access the shared blacklistAKIA0000000000000000
AWS_SECRET_ACCESS_KEYSpecifies the secret key associated with the access key. This is essentially the "password" for the access key. Used to access the shared blacklist0000000000000000000000000000000000000
AWS_DEFAULT_REGIONSpecifies the AWS Region to send the request to. Used to access the shared blacklistus-east-1
SES_RATE_LIMITSpecifies the maximum emails per second you are allowed to send per second10
SMTP_HOSTSpecifies the host to listen on0.0.0.0
SMTP_PORTSpecifies the port to listen on1025
AWS_SMTP_HOSTSpecifies the AWS SES SMTP host to talk toemail-smtp.us-east-1.amazonaws.com
AWS_SMTP_PORTSpecifies the AWS SES SMTP port to talk to587
AWS_SMTP_USERNAMESpecifies the AWS SES SMTP usernameAKIA0000000000000000
AWS_SMTP_PASSWORDSpecifies the AWS SES SMTP usernameABCDEF/GHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR

Lambda Environment Variables

Environment VariableDetailsExample
SES_REGIONThe region that SES is working inus-east-1
EMAIL_FROMThe email address to send emails from[email protected]
EMAIL_TOThe list of email addresses to send to, separated by semicolons[email protected];[email protected]

IAM Roles

Here are the permissions required to run the Email Blacklist Lambda

Email Blacklist Lambda

Here are the permissions required to run the Email Blacklist Lambda

Email Blacklist Policy
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail",
                "ses:SendRawEmail"
            ],
            "Resource": [
                "arn:aws:ses:<REGION>:<ACCOUNT_ID>:identity/<SES_DOMAIN>"
            ]
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "sns:ConfirmSubscription",
                "sns:Subscribe",
                "sns:Unsubscribe"
            ],
            "Resource": [
                "arn:aws:sns:<REGION>:<ACCOUNT_ID>:<SNS_TOPIC_NAME>"
            ]
        },
        {
            "Sid": "VisualEditor2",
            "Effect": "Allow",
            "Action": [
                "dynamodb:PutItem"
            ],
            "Resource": "arn:aws:dynamodb:<REGION>:<ACCOUNT_ID>:table/<DYNAMODB_TABLE_NAME>"
        }
    ]
}
Email Blacklist Trust Relationship
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "sns.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
Email Blacklist DynamoDB Access

Here are the permissions required to access the Email Blacklist from the SES Service (BLACKLIST_AWS_ACCESS_KEY_ID and adjacent environment variables)

Email Blacklist DynamoDB Policy
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "dynamodb:GetItem",
            "Resource": "arn:aws:dynamodb:<REGION>:<ACCOUNT_ID>:table/<TABLE_NAME>"
        }
    ]
}

Tag summary

Content type

Image

Digest

Size

44.8 MB

Last updated

almost 7 years ago

docker pull clevyr/ses-email-service