Camel Components

AWS Simple Email Service (SES)

Since Camel 3.1

Only producer is supported

The AWS2 SES component supports sending emails with Amazon’s SES service.

Prerequisites

You must have a valid Amazon Web Services developer account, and be signed up to use Amazon SES. More information is available at Amazon SES.

URI Format

aws2-ses://from[?options]

You can append query options to the URI in the following format:

?options=value&option2=value&…​

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The AWS Simple Email Service (SES) component supports the following options which are listed below.

Name Description Default Type

bcc (producer)

The email addresses of the Bcc (blind carbon copy) recipients, as a comma-separated list. The CamelAwsSesBcc header replaces this option. For a raw mail, see the to option.

String

cc (producer)

The email addresses of the Cc (carbon copy) recipients, as a comma-separated list. The CamelAwsSesCc header replaces this option. For a raw mail, see the to option.

String

configuration (producer)

The configuration that the endpoints of this component start from. Each endpoint gets a copy of it, and the options of the endpoint replace its values.

Ses2Configuration

configurationSet (producer)

The name of the configuration set of Amazon SES to send the mail with, for example to publish its sending events. The CamelAwsSesConfigurationSet header replaces this option. It is used for a raw mail too.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

region (producer)

The AWS region of Amazon SES, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. The sender identity must be verified in this region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

replyToAddresses (producer)

The reply-to email addresses of the mail, as a comma-separated list. The CamelAwsSesReplyToAddresses header replaces this option. It is not used for a raw mail.

String

returnPath (producer)

The email address that Amazon SES forwards bounces and complaints to when email feedback forwarding is enabled. The address itself or its domain must be verified in Amazon SES. The CamelAwsSesReturnPath header replaces this option. It is not used for a raw mail.

String

subject (producer)

The subject of the mail. The CamelAwsSesSubject header replaces this option. Amazon SES requires a subject, unless the body is a raw mail, which has its own subject and does not use this option.

String

to (producer)

The email addresses of the To recipients, as a comma-separated list. The CamelAwsSesTo header replaces this option. For a raw mail, the addresses of the to, cc and bcc options are the recipients that Amazon SES sends the mail to, and the To, Cc and Bcc headers of the mail stay as they are. When none is set, Amazon SES sends a raw mail to the recipients in its To, Cc and Bcc headers.

String

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

amazonSESClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.ses.SesClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

SesClient

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

healthCheckConsumerEnabled (health)

Used for enabling or disabling all consumer based health checks from this component.

true

boolean

healthCheckProducerEnabled (health)

Used for enabling or disabling all producer based health checks from this component. Notice: Camel has by default disabled all producer based health-checks. You can turn on producer checks globally by setting camel.health.producersEnabled=true.

true

boolean

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon SES connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon SES connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon SES uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless amazonSESClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

profileCredentialsName (security)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless amazonSESClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

trustAllCertificates (security)

Whether the HTTP client of Amazon SES trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useDefaultCredentialsProvider (security)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (security)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Endpoint Options

The AWS Simple Email Service (SES) endpoint is configured using URI syntax:

aws2-ses:from

With the following path and query parameters:

Path Parameters

Name Description Default Type

from (producer)

Required The email address of the sender, which is the source of the mail. Amazon SES sends only from a verified identity: the address itself or its domain must be verified. The CamelAwsSesFrom header replaces it.

String

Query Parameters

Name Description Default Type

bcc (producer)

The email addresses of the Bcc (blind carbon copy) recipients, as a comma-separated list. The CamelAwsSesBcc header replaces this option. For a raw mail, see the to option.

String

cc (producer)

The email addresses of the Cc (carbon copy) recipients, as a comma-separated list. The CamelAwsSesCc header replaces this option. For a raw mail, see the to option.

String

configurationSet (producer)

The name of the configuration set of Amazon SES to send the mail with, for example to publish its sending events. The CamelAwsSesConfigurationSet header replaces this option. It is used for a raw mail too.

String

overrideEndpoint (producer)

Whether to send the requests to the URI of the uriEndpointOverride option instead of the endpoint of the region. It has no effect when uriEndpointOverride is not set.

false

boolean

region (producer)

The AWS region of Amazon SES, as a region ID such as eu-west-1, which is the value of Region.EU_WEST_1.id(). If not set, the default region provider chain of the AWS SDK is used. The sender identity must be verified in this region.

Enum values:

  • ap-south-2

  • ap-south-1

  • eu-south-1

  • eu-south-2

  • us-gov-east-1

  • me-central-1

  • il-central-1

  • ca-central-1

  • eu-central-1

  • us-iso-west-1

  • eu-central-2

  • eu-isoe-west-1

  • us-west-1

  • us-west-2

  • af-south-1

  • eu-north-1

  • eu-west-3

  • eu-west-2

  • eu-west-1

  • ap-northeast-3

  • ap-northeast-2

  • ap-northeast-1

  • me-south-1

  • sa-east-1

  • ap-east-1

  • cn-north-1

  • ca-west-1

  • us-gov-west-1

  • ap-southeast-1

  • ap-southeast-2

  • us-iso-east-1

  • ap-southeast-3

  • ap-southeast-4

  • us-east-1

  • us-east-2

  • cn-northwest-1

  • us-isob-east-1

  • aws-global

  • aws-cn-global

  • aws-us-gov-global

  • aws-iso-global

  • aws-iso-b-global

String

replyToAddresses (producer)

The reply-to email addresses of the mail, as a comma-separated list. The CamelAwsSesReplyToAddresses header replaces this option. It is not used for a raw mail.

String

returnPath (producer)

The email address that Amazon SES forwards bounces and complaints to when email feedback forwarding is enabled. The address itself or its domain must be verified in Amazon SES. The CamelAwsSesReturnPath header replaces this option. It is not used for a raw mail.

String

subject (producer)

The subject of the mail. The CamelAwsSesSubject header replaces this option. Amazon SES requires a subject, unless the body is a raw mail, which has its own subject and does not use this option.

String

to (producer)

The email addresses of the To recipients, as a comma-separated list. The CamelAwsSesTo header replaces this option. For a raw mail, the addresses of the to, cc and bcc options are the recipients that Amazon SES sends the mail to, and the To, Cc and Bcc headers of the mail stay as they are. When none is set, Amazon SES sends a raw mail to the recipients in its To, Cc and Bcc headers.

String

uriEndpointOverride (producer)

The URI of the endpoint to use instead of the endpoint of the region, for example http://localhost:4566 for a local emulator. It is used only when overrideEndpoint is true.

String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

amazonSESClient (advanced)

Autowired To use a custom software.amazon.awssdk.services.ses.SesClient, which is autowired when the registry has a single one. When this option is set, the credentials, region, proxy, endpoint override and trustAllCertificates options are not used. The endpoint does not close a client that is set or autowired.

SesClient

proxyHost (proxy)

The host name of the proxy that the HTTP client of Amazon SES connects through. The proxy is used only when the proxyPort option is set too.

String

proxyPort (proxy)

The port of the proxy that the HTTP client of Amazon SES connects through. The proxy is used only when the proxyHost option is set too.

Integer

proxyProtocol (proxy)

The protocol that the HTTP client of Amazon SES uses to connect to the proxy. It is used only when the proxyHost and proxyPort options are set.

Enum values:

  • HTTP

  • HTTPS

HTTPS

Protocol

accessKey (security)

The access key ID of the AWS credentials, used together with the secretKey option. The endpoint requires it, unless amazonSESClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

profileCredentialsName (security)

The name of the profile in the AWS shared credentials and config files, used when useProfileCredentialsProvider is true. If not set, the AWS SDK uses its default profile, which the AWS_PROFILE environment variable can change.

String

secretKey (security)

The secret access key of the AWS credentials, used together with the accessKey option. The endpoint requires it, unless amazonSESClient is set or useDefaultCredentialsProvider or useProfileCredentialsProvider is true. It is also required when useSessionCredentials is true.

String

sessionToken (security)

The session token of temporary AWS credentials, for example of an assumed IAM role. It is used only when useSessionCredentials is true, together with the accessKey and secretKey options. All three are then required: if one of the three is missing, creating the client fails.

String

trustAllCertificates (security)

Whether the HTTP client of Amazon SES trusts every TLS certificate without checking it. It applies to any endpoint, not only to an overridden one, so use it only for testing, for example against a local emulator.

false

boolean

useDefaultCredentialsProvider (security)

Whether to load the credentials with the default credentials provider chain of the AWS SDK, which looks in system properties, environment variables, the shared credentials and config files, and the container or instance role. It takes precedence over the other credentials options.

false

boolean

useProfileCredentialsProvider (security)

Whether to load the credentials from a profile of the AWS shared credentials and config files, the one of the profileCredentialsName option. It is not used when useDefaultCredentialsProvider is true, and it takes precedence over the session and static credentials.

false

boolean

useSessionCredentials (security)

Whether to use temporary credentials made of the accessKey, secretKey and sessionToken options, for example those of an assumed IAM role. It is not used when useDefaultCredentialsProvider or useProfileCredentialsProvider is true.

false

boolean

Message Headers

The AWS Simple Email Service (SES) component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelAwsSesFrom (producer)

Constant: FROM

The email address of the sender. It replaces the from of the endpoint.

String

CamelAwsSesMessageId (producer)

Constant: MESSAGE_ID

The ID of the mail that Amazon SES returns, which the producer sets after sending the mail.

String

CamelAwsSesReplyToAddresses (producer)

Constant: REPLY_TO_ADDRESSES

The reply-to email addresses of the mail, as a comma-separated list. It replaces the replyToAddresses option. It is not used for a raw mail.

String

CamelAwsSesReturnPath (producer)

Constant: RETURN_PATH

The email address that Amazon SES forwards bounces and complaints to when email feedback forwarding is enabled. It replaces the returnPath option. It is not used for a raw mail.

String

CamelAwsSesSubject (producer)

Constant: SUBJECT

The subject of the mail. It replaces the subject option. It is not used for a raw mail.

String

CamelAwsSesTo (producer)

Constant: TO

The email addresses of the To recipients, as a comma-separated list. It replaces the to option.

String

CamelAwsSesCc (producer)

Constant: CC

The email addresses of the Cc (carbon copy) recipients, as a comma-separated list. It replaces the cc option.

String

CamelAwsSesBcc (producer)

Constant: BCC

The email addresses of the Bcc (blind carbon copy) recipients, as a comma-separated list. It replaces the bcc option.

String

CamelAwsSesTags (producer)

Constant: TAGS

The message tags of the mail, as a Map of tag name to tag value. Amazon SES includes them in the sending events that a configuration set publishes. It is used for a raw mail too.

Map

CamelAwsSesHtmlEmail (producer)

Constant: HTML_EMAIL

Whether the body is the HTML of the mail instead of its plain text, which it is when the header is not set. It is not used for a raw mail.

Boolean

CamelAwsSesConfigurationSet (producer)

Constant: CONFIGURATION_SET

The name of the configuration set of Amazon SES to send the mail with. It replaces the configurationSet option.

String

Message Body

The message body at each side of the AWS Simple Email Service (SES) component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

text, bytes, stream or file

The text of the mail, or its HTML with the CamelAwsSesHtmlEmail header set to true: bytes, a stream or a file are read as text, and a Map or a POJO is sent as its toString(), so marshal it first. A jakarta.mail Message or a RawMessage is sent as a raw mail as it is, a SendRawEmailRequest is sent as the request, and no body fails.

Producer output

unchanged

Unchanged, with the id of the mail in the CamelAwsSesMessageId header.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Required SES component options

You have to provide the amazonSESClient in the Registry or your accessKey and secretKey to access the Amazon’s SES.

Usage

Static credentials, Default Credential Provider and Profile Credentials Provider

You have the possibility of avoiding the usage of explicit static credentials by specifying the useDefaultCredentialsProvider option and set it to true.

The order of evaluation for Default Credentials Provider is the following:

  • Java system properties - aws.accessKeyId and aws.secretKey.

  • Environment variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

  • Web Identity Token from AWS STS.

  • The shared credentials and config files.

  • Amazon ECS container credentials - loaded from the Amazon ECS if the environment variable AWS_CONTAINER_CREDENTIALS_RELATIVE_URI is set.

  • Amazon EC2 Instance profile credentials.

You have also the possibility of using Profile Credentials Provider, by specifying the useProfileCredentialsProvider option to true and profileCredentialsName to the profile name.

Only one of static, default and profile credentials could be used at the same time.

For more information about this you can look at AWS credentials documentation

Advanced SesClient configuration

If you need more control over the SesClient instance configuration you can create your own instance and refer to it from the URI:

  • Java

  • XML

  • YAML

from("direct:start")
    .to("aws2-ses://example@example.com?amazonSESClient=#client");
<route>
  <from uri="direct:start"/>
  <to uri="aws2-ses://example@example.com?amazonSESClient=#client"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - to:
            uri: aws2-ses://example@example.com
            parameters:
              amazonSESClient: "#client"

The #client refers to a SesClient in the Registry.

Message body

The producer sends the message body as follows:

Body Sent as

text (a String, or any body converted to a String)

a plain mail (sendEmail) with the body as its text, or its HTML when the CamelAwsSesHtmlEmail header is true, and the subject, recipients and other fields of the options or headers.

jakarta.mail.Message

a raw mail (sendRawEmail) with the MIME content of the message.

software.amazon.awssdk.services.ses.model.RawMessage

a raw mail (sendRawEmail) with the MIME content of the RawMessage.

software.amazon.awssdk.services.ses.model.SendRawEmailRequest

the request as it is (sendRawEmail); the options and headers are not used.

For a raw mail (a jakarta.mail.Message or RawMessage body), the source is the from option or the CamelAwsSesFrom header, and the destinations are the addresses of the to, cc and bcc options or the CamelAwsSesTo, CamelAwsSesCc and CamelAwsSesBcc headers. When none of them is set, SES sends the mail to the recipients of the To, Cc and Bcc headers of the raw mail. The subject is the one of the raw mail.

A message without a body fails with an InvalidPayloadException, and nothing is sent to SES.

The to, cc, bcc and replyToAddresses options and their headers are a String; give several addresses as a comma-separated list, such as to1@example.com,to2@example.com.

Examples

Producer Examples

  • Java

  • XML

  • YAML

from("direct:start")
    .setHeader(Ses2Constants.SUBJECT, constant("This is my subject"))
    .setHeader(Ses2Constants.TO, constant("to@example.com"))
    .setBody(constant("This is my message text."))
    .to("aws2-ses://from@example.com?accessKey=xxx&secretKey=yyy");
<route>
    <from uri="direct:start"/>
    <setHeader name="CamelAwsSesSubject">
        <constant>This is my subject</constant>
    </setHeader>
    <setHeader name="CamelAwsSesTo">
        <constant>to@example.com</constant>
    </setHeader>
    <setBody>
        <constant>This is my message text.</constant>
    </setBody>
    <to uri="aws2-ses://from@example.com?accessKey=xxx&amp;secretKey=yyy"/>
</route>
- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelAwsSesSubject
            constant: "This is my subject"
        - setHeader:
            name: CamelAwsSesTo
            constant: "to@example.com"
        - setBody:
            constant: "This is my message text."
        - to:
            uri: aws2-ses://from@example.com
            parameters:
              accessKey: xxx
              secretKey: yyy

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-aws2-ses</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel.