Package software.amazon.awscdk.services.ses
Amazon Simple Email Service Construct Library
This module is part of the AWS Cloud Development Kit project.
Email receiving
Create a receipt rule set with rules and actions (actions can be found in the
aws-cdk-lib/aws-ses-actions package):
import software.amazon.awscdk.services.s3.*;
import software.amazon.awscdk.services.ses.actions.*;
Bucket bucket = new Bucket(this, "Bucket");
Topic topic = new Topic(this, "Topic");
ReceiptRuleSet.Builder.create(this, "RuleSet")
.rules(List.of(ReceiptRuleOptions.builder()
.recipients(List.of("hello@aws.com"))
.actions(List.of(
AddHeader.Builder.create()
.name("X-Special-Header")
.value("aws")
.build(),
S3.Builder.create()
.bucket(bucket)
.objectKeyPrefix("emails/")
.topic(topic)
.build()))
.build(), ReceiptRuleOptions.builder()
.recipients(List.of("aws.com"))
.actions(List.of(
Sns.Builder.create()
.topic(topic)
.build()))
.build()))
.build();
Alternatively, rules can be added to a rule set:
ReceiptRuleSet ruleSet = new ReceiptRuleSet(this, "RuleSet");
ReceiptRule awsRule = ruleSet.addRule("Aws", ReceiptRuleOptions.builder()
.recipients(List.of("aws.com"))
.build());
And actions to rules:
import software.amazon.awscdk.services.ses.actions.*;
ReceiptRule awsRule;
Topic topic;
awsRule.addAction(Sns.Builder.create()
.topic(topic)
.build());
When using addRule, the new rule is added after the last added rule unless after is specified.
Drop spams
A rule to drop spam can be added by setting dropSpam to true:
ReceiptRuleSet.Builder.create(this, "RuleSet")
.dropSpam(true)
.build();
This will add a rule at the top of the rule set with a Lambda action that stops processing messages that have at least one spam indicator. See Lambda Function Examples.
Receipt filter
Create a receipt filter:
ReceiptFilter.Builder.create(this, "Filter")
.ip("1.2.3.4/16")
.build();
An allow list filter is also available:
AllowListReceiptFilter.Builder.create(this, "AllowList")
.ips(List.of("10.0.0.0/16", "1.2.3.4/16"))
.build();
This will first create a block all filter and then create allow filters for the listed ip addresses.
Email sending
Dedicated IP pools
When you create a new Amazon SES account, your emails are sent from IP addresses that are shared with other Amazon SES users. For an additional monthly charge, you can lease dedicated IP addresses that are reserved for your exclusive use.
Use the DedicatedIpPool construct to create a pool of dedicated IP addresses:
new DedicatedIpPool(this, "Pool");
The pool can then be used in a configuration set.
Configuration sets
Configuration sets are groups of rules that you can apply to your verified identities. A verified identity is a domain, subdomain, or email address you use to send email through Amazon SES. When you apply a configuration set to an email, all of the rules in that configuration set are applied to the email.
Use the ConfigurationSet construct to create a configuration set:
IDedicatedIpPool myPool;
ConfigurationSet.Builder.create(this, "ConfigurationSet")
.customTrackingRedirectDomain("track.cdk.dev")
.suppressionReasons(SuppressionReasons.COMPLAINTS_ONLY)
.tlsPolicy(ConfigurationSetTlsPolicy.REQUIRE)
.dedicatedIpPool(myPool)
.build();
Use addEventDestination() to publish email sending events to Amazon SNS or Amazon CloudWatch:
ConfigurationSet myConfigurationSet;
Topic myTopic;
myConfigurationSet.addEventDestination("ToSns", ConfigurationSetEventDestinationOptions.builder()
.destination(EventDestination.snsTopic(myTopic))
.build());
Email identity
In Amazon SES, a verified identity is a domain or email address that you use to send or receive email. Before you
can send an email using Amazon SES, you must create and verify each identity that you're going to use as a From,
Source, Sender, or Return-Path address. Verifying an identity with Amazon SES confirms that you own it and
helps prevent unauthorized use.
To verify an identity for a hosted zone, you create an EmailIdentity:
IPublicHostedZone myHostedZone;
EmailIdentity identity = EmailIdentity.Builder.create(this, "Identity")
.identity(Identity.publicHostedZone(myHostedZone))
.mailFromDomain("mail.cdk.dev")
.build();
By default, Easy DKIM with a 2048-bit DKIM key is used.
You can instead configure DKIM authentication by using your own public-private key pair. This process is known as Bring Your Own DKIM (BYODKIM):
IPublicHostedZone myHostedZone;
EmailIdentity.Builder.create(this, "Identity")
.identity(Identity.publicHostedZone(myHostedZone))
.dkimIdentity(DkimIdentity.byoDkim(ByoDkimOptions.builder()
.privateKey(SecretValue.secretsManager("dkim-private-key"))
.publicKey("...base64-encoded-public-key...")
.selector("selector")
.build()))
.build();
When using publicHostedZone() for the identity, all necessary Amazon Route 53 records are created automatically:
- CNAME records for Easy DKIM
- TXT record for BYOD DKIM
- MX and TXT records for the custom MAIL FROM
When working with domain(), records must be created manually:
EmailIdentity identity = EmailIdentity.Builder.create(this, "Identity")
.identity(Identity.domain("cdk.dev"))
.build();
for (Object record : identity.getDkimRecords()) {
}
Virtual Deliverability Manager (VDM)
Virtual Deliverability Manager is an Amazon SES feature that helps you enhance email deliverability, like increasing inbox deliverability and email conversions, by providing insights into your sending and delivery data, and giving advice on how to fix the issues that are negatively affecting your delivery success rate and reputation.
Use the VdmAttributes construct to configure the Virtual Deliverability Manager for your account:
// Enables engagement tracking and optimized shared delivery by default // Enables engagement tracking and optimized shared delivery by default new VdmAttributes(this, "Vdm");
-
ClassDescriptionAddHeaderAction configuration.A builder for
AddHeaderActionConfigAn implementation forAddHeaderActionConfigAn allow list receipt filter.A fluent builder forAllowListReceiptFilter.Construction properties for am AllowListReceiptFilter.A builder forAllowListReceiptFilterPropsAn implementation forAllowListReceiptFilterPropsBoundAction configuration.A builder forBounceActionConfigAn implementation forBounceActionConfigOptions for BYO DKIM.A builder forByoDkimOptionsAn implementation forByoDkimOptionsConfiguration sets let you create groups of rules that you can apply to the emails you send using Amazon SES.A fluent builder forCfnConfigurationSet.Settings for your VDM configuration as applicable to the Dashboard.A builder forCfnConfigurationSet.DashboardOptionsPropertyAn implementation forCfnConfigurationSet.DashboardOptionsPropertySpecifies whether messages that use the configuration set are required to use Transport Layer Security (TLS).A builder forCfnConfigurationSet.DeliveryOptionsPropertyAn implementation forCfnConfigurationSet.DeliveryOptionsPropertySettings for your VDM configuration as applicable to the Guardian.A builder forCfnConfigurationSet.GuardianOptionsPropertyAn implementation forCfnConfigurationSet.GuardianOptionsPropertyContains information about the reputation settings for a configuration set.A builder forCfnConfigurationSet.ReputationOptionsPropertyAn implementation forCfnConfigurationSet.ReputationOptionsPropertyUsed to enable or disable email sending for messages that use this configuration set in the current AWS Region.A builder forCfnConfigurationSet.SendingOptionsPropertyAn implementation forCfnConfigurationSet.SendingOptionsPropertyAn object that contains information about the suppression list preferences for your account.A builder forCfnConfigurationSet.SuppressionOptionsPropertyAn implementation forCfnConfigurationSet.SuppressionOptionsPropertyA domain that is used to redirect email recipients to an Amazon SES-operated domain.A builder forCfnConfigurationSet.TrackingOptionsPropertyAn implementation forCfnConfigurationSet.TrackingOptionsPropertyThe Virtual Deliverability Manager (VDM) options that apply to a configuration set.A builder forCfnConfigurationSet.VdmOptionsPropertyAn implementation forCfnConfigurationSet.VdmOptionsPropertySpecifies a configuration set event destination.A fluent builder forCfnConfigurationSetEventDestination.Contains information associated with an Amazon CloudWatch event destination to which email sending events are published.An implementation forCfnConfigurationSetEventDestination.CloudWatchDestinationPropertyContains the dimension configuration to use when you publish email sending events to Amazon CloudWatch.An implementation forCfnConfigurationSetEventDestination.DimensionConfigurationPropertyContains information about an event destination.An implementation forCfnConfigurationSetEventDestination.EventDestinationPropertyContains the delivery stream ARN and the IAM role ARN associated with an Amazon Kinesis Firehose event destination.An implementation forCfnConfigurationSetEventDestination.KinesisFirehoseDestinationPropertyContains the topic ARN associated with an Amazon Simple Notification Service (Amazon SNS) event destination.An implementation forCfnConfigurationSetEventDestination.SnsDestinationPropertyProperties for defining aCfnConfigurationSetEventDestination.A builder forCfnConfigurationSetEventDestinationPropsAn implementation forCfnConfigurationSetEventDestinationPropsProperties for defining aCfnConfigurationSet.A builder forCfnConfigurationSetPropsAn implementation forCfnConfigurationSetPropsA list that contains contacts that have subscribed to a particular topic or topics.A fluent builder forCfnContactList.An interest group, theme, or label within a list.A builder forCfnContactList.TopicPropertyAn implementation forCfnContactList.TopicPropertyProperties for defining aCfnContactList.A builder forCfnContactListPropsAn implementation forCfnContactListPropsCreate a new pool of dedicated IP addresses.A fluent builder forCfnDedicatedIpPool.Properties for defining aCfnDedicatedIpPool.A builder forCfnDedicatedIpPoolPropsAn implementation forCfnDedicatedIpPoolPropsSpecifies an identity for using within SES.A fluent builder forCfnEmailIdentity.Used to associate a configuration set with an email identity.A builder forCfnEmailIdentity.ConfigurationSetAttributesPropertyAn implementation forCfnEmailIdentity.ConfigurationSetAttributesPropertyUsed to enable or disable DKIM authentication for an email identity.A builder forCfnEmailIdentity.DkimAttributesPropertyAn implementation forCfnEmailIdentity.DkimAttributesPropertyUsed to configure or change the DKIM authentication settings for an email domain identity.A builder forCfnEmailIdentity.DkimSigningAttributesPropertyAn implementation forCfnEmailIdentity.DkimSigningAttributesPropertyUsed to enable or disable feedback forwarding for an identity.A builder forCfnEmailIdentity.FeedbackAttributesPropertyAn implementation forCfnEmailIdentity.FeedbackAttributesPropertyUsed to enable or disable the custom Mail-From domain configuration for an email identity.A builder forCfnEmailIdentity.MailFromAttributesPropertyAn implementation forCfnEmailIdentity.MailFromAttributesPropertyProperties for defining aCfnEmailIdentity.A builder forCfnEmailIdentityPropsAn implementation forCfnEmailIdentityPropsSpecify a new IP address filter.A fluent builder forCfnReceiptFilter.Specifies an IP address filter.A builder forCfnReceiptFilter.FilterPropertyAn implementation forCfnReceiptFilter.FilterPropertyA receipt IP address filter enables you to specify whether to accept or reject mail originating from an IP address or range of IP addresses.A builder forCfnReceiptFilter.IpFilterPropertyAn implementation forCfnReceiptFilter.IpFilterPropertyProperties for defining aCfnReceiptFilter.A builder forCfnReceiptFilterPropsAn implementation forCfnReceiptFilterPropsSpecifies a receipt rule.An action that Amazon SES can take when it receives an email on behalf of one or more email addresses or domains that you own.A builder forCfnReceiptRule.ActionPropertyAn implementation forCfnReceiptRule.ActionPropertyWhen included in a receipt rule, this action adds a header to the received email.A builder forCfnReceiptRule.AddHeaderActionPropertyAn implementation forCfnReceiptRule.AddHeaderActionPropertyWhen included in a receipt rule, this action rejects the received email by returning a bounce response to the sender and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.BounceActionPropertyAn implementation forCfnReceiptRule.BounceActionPropertyA fluent builder forCfnReceiptRule.When included in a receipt rule, this action calls an AWS Lambda function and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.LambdaActionPropertyAn implementation forCfnReceiptRule.LambdaActionPropertyReceipt rules enable you to specify which actions Amazon SES should take when it receives mail on behalf of one or more email addresses or domains that you own.A builder forCfnReceiptRule.RulePropertyAn implementation forCfnReceiptRule.RulePropertyWhen included in a receipt rule, this action saves the received message to an Amazon Simple Storage Service (Amazon S3) bucket and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.S3ActionPropertyAn implementation forCfnReceiptRule.S3ActionPropertyWhen included in a receipt rule, this action publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.SNSActionPropertyAn implementation forCfnReceiptRule.SNSActionPropertyWhen included in a receipt rule, this action terminates the evaluation of the receipt rule set and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.StopActionPropertyAn implementation forCfnReceiptRule.StopActionPropertyWhen included in a receipt rule, this action calls Amazon WorkMail and, optionally, publishes a notification to Amazon Simple Notification Service (Amazon SNS).A builder forCfnReceiptRule.WorkmailActionPropertyAn implementation forCfnReceiptRule.WorkmailActionPropertyProperties for defining aCfnReceiptRule.A builder forCfnReceiptRulePropsAn implementation forCfnReceiptRulePropsCreates an empty receipt rule set.A fluent builder forCfnReceiptRuleSet.Properties for defining aCfnReceiptRuleSet.A builder forCfnReceiptRuleSetPropsAn implementation forCfnReceiptRuleSetPropsSpecifies an email template.A fluent builder forCfnTemplate.The content of the email, composed of a subject line and either an HTML part or a text-only part.A builder forCfnTemplate.TemplatePropertyAn implementation forCfnTemplate.TemplatePropertyProperties for defining aCfnTemplate.A builder forCfnTemplatePropsAn implementation forCfnTemplatePropsThe Virtual Deliverability Manager (VDM) attributes that apply to your Amazon SES account.A fluent builder forCfnVdmAttributes.Settings for your VDM configuration as applicable to the Dashboard.A builder forCfnVdmAttributes.DashboardAttributesPropertyAn implementation forCfnVdmAttributes.DashboardAttributesPropertySettings for your VDM configuration as applicable to the Guardian.A builder forCfnVdmAttributes.GuardianAttributesPropertyAn implementation forCfnVdmAttributes.GuardianAttributesPropertyProperties for defining aCfnVdmAttributes.A builder forCfnVdmAttributesPropsAn implementation forCfnVdmAttributesPropsA CloudWatch dimension upon which to categorize your emails.A builder forCloudWatchDimensionAn implementation forCloudWatchDimensionSource for CloudWatch dimension.A configuration set.A fluent builder forConfigurationSet.A configuration set event destination.A fluent builder forConfigurationSetEventDestination.Options for a configuration set event destination.A builder forConfigurationSetEventDestinationOptionsAn implementation forConfigurationSetEventDestinationOptionsProperties for a configuration set event destination.A builder forConfigurationSetEventDestinationPropsAn implementation forConfigurationSetEventDestinationPropsProperties for a configuration set.A builder forConfigurationSetPropsAn implementation forConfigurationSetPropsTLS policy for a configuration set.A dedicated IP pool.A fluent builder forDedicatedIpPool.Properties for a dedicated IP pool.A builder forDedicatedIpPoolPropsAn implementation forDedicatedIpPoolPropsThe identity to use for DKIM.Configuration for DKIM identity.A builder forDkimIdentityConfigAn implementation forDkimIdentityConfigA DKIM record.A builder forDkimRecordAn implementation forDkimRecordA rule added at the top of the rule set to drop spam/virus.A fluent builder forDropSpamReceiptRule.Example:A builder forDropSpamReceiptRulePropsAn implementation forDropSpamReceiptRulePropsThe signing key length for Easy DKIM.An email identity.A fluent builder forEmailIdentity.Properties for an email identity.A builder forEmailIdentityPropsAn implementation forEmailIdentityPropsEmail sending event.An event destination.A configuration set.Internal default implementation forIConfigurationSet.A proxy class which represents a concrete javascript instance of this type.A configuration set event destination.Internal default implementation forIConfigurationSetEventDestination.A proxy class which represents a concrete javascript instance of this type.A dedicated IP pool.Internal default implementation forIDedicatedIpPool.A proxy class which represents a concrete javascript instance of this type.Identity.An email identity.Internal default implementation forIEmailIdentity.A proxy class which represents a concrete javascript instance of this type.A receipt rule.Internal default implementation forIReceiptRule.A proxy class which represents a concrete javascript instance of this type.An abstract action for a receipt rule.Internal default implementation forIReceiptRuleAction.A proxy class which represents a concrete javascript instance of this type.A receipt rule set.Internal default implementation forIReceiptRuleSet.A proxy class which represents a concrete javascript instance of this type.Virtual Deliverablity Manager (VDM) attributes.Internal default implementation forIVdmAttributes.A proxy class which represents a concrete javascript instance of this type.LambdaAction configuration.A builder forLambdaActionConfigAn implementation forLambdaActionConfigThe action to take if the required MX record for the MAIL FROM domain isn't found.A receipt filter.A fluent builder forReceiptFilter.The policy for the receipt filter.Construction properties for a ReceiptFilter.A builder forReceiptFilterPropsAn implementation forReceiptFilterPropsA new receipt rule.A fluent builder forReceiptRule.Properties for a receipt rule action.A builder forReceiptRuleActionConfigAn implementation forReceiptRuleActionConfigOptions to add a receipt rule to a receipt rule set.A builder forReceiptRuleOptionsAn implementation forReceiptRuleOptionsConstruction properties for a ReceiptRule.A builder forReceiptRulePropsAn implementation forReceiptRulePropsA new receipt rule set.A fluent builder forReceiptRuleSet.Construction properties for a ReceiptRuleSet.A builder forReceiptRuleSetPropsAn implementation forReceiptRuleSetPropsS3Action configuration.A builder forS3ActionConfigAn implementation forS3ActionConfigSNSAction configuration.A builder forSNSActionConfigAn implementation forSNSActionConfigStopAction configuration.A builder forStopActionConfigAn implementation forStopActionConfigReasons for which recipient email addresses should be automatically added to your account's suppression list.The type of TLS policy for a receipt rule.Virtual Deliverablity Manager (VDM) attributes.A fluent builder forVdmAttributes.Properties for the Virtual Deliverablity Manager (VDM) attributes.A builder forVdmAttributesPropsAn implementation forVdmAttributesPropsWorkmailAction configuration.A builder forWorkmailActionConfigAn implementation forWorkmailActionConfig