Search code examples
amazon-ses

SES rule to only allow mail to a specific domain


Is it possible to configure SES to only send mails to certain domains?

I'm having problems finding such a feature in the AWS documentation.


Solution

  • Yes, by configuring appropriate IAM policies you will be able to restrict e-mail sending to certain domains and recipient emails.

    Configure the policy on the account or group of the SES IAM user that sends the e-mails

    A sample excerpt is below.

        {
          "Version":"2012-10-17",
          "Statement":[
            {
              "Effect":"Allow",
              "Action":[
                "ses:SendEmail",
                "ses:SendRawEmail"
              ],
              "Resource":"*",
              "Condition":{
                "ForAllValues:StringLike":{
                  "ses:Recipients":[
                    "*@example.com"
                  ]
                }
              }
            }
          ]
        }
    

    Additionally, you can restrict the emails on fromAddress, FromDisplaynames, etc.

    Reference : SES Policies