Camel Spring Boot Starter for mail

Spring Boot Auto-Configuration

When using mail with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-mail-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 50 options, which are listed below.

Name Description Default Type

camel.component.mail.additional-java-mail-properties

Sets additional java mail properties, that will append/override any default properties that is set based on all the other options. This is useful if you need to add some special options but want to keep the others as is. The option is a java.util.Properties type.

String

camel.component.mail.alternative-body-header

Specifies the key to an IN message header that contains an alternative email body. For example, if you send emails in text/html format and want to provide an alternative mail body for non-HTML email clients, set the alternative mail body with this key as a header.

CamelMailAlternativeBody

String

camel.component.mail.attachments-content-transfer-encoding-resolver

To use a custom AttachmentsContentTransferEncodingResolver to resolve what content-type-encoding to use for attachments. The option is a org.apache.camel.component.mail.AttachmentsContentTransferEncodingResolver type.

String

camel.component.mail.authenticator

The authenticator for login. If set then the password and username are ignored. Can be used for tokens which can expire and therefore must be read dynamically. The option is a org.apache.camel.component.mail.MailAuthenticator type.

String

camel.component.mail.basic-property-binding

Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities

false

Boolean

camel.component.mail.bcc

Sets the BCC email address. Separate multiple email addresses with comma.

String

camel.component.mail.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.mail.cc

Sets the CC email address. Separate multiple email addresses with comma.

String

camel.component.mail.close-folder

Whether the consumer should close the folder after polling. Setting this option to false and having disconnect=false as well, then the consumer keep the folder open between polls.

true

Boolean

camel.component.mail.configuration

Sets the Mail configuration. The option is a org.apache.camel.component.mail.MailConfiguration type.

String

camel.component.mail.connection-timeout

The connection timeout in milliseconds.

30000

Integer

camel.component.mail.content-type

The mail message content type. Use text/html for HTML mails.

text/plain

String

camel.component.mail.content-type-resolver

Resolver to determine Content-Type for file attachments. The option is a org.apache.camel.component.mail.ContentTypeResolver type.

String

camel.component.mail.copy-to

After processing a mail message, it can be copied to a mail folder with the given name. You can override this configuration value, with a header with the key copyTo, allowing you to copy messages to folder names configured at runtime.

String

camel.component.mail.debug-mode

Enable debug mode on the underlying mail framework. The SUN Mail framework logs the debug messages to System.out by default.

false

Boolean

camel.component.mail.delete

Deletes the messages after they have been processed. This is done by setting the DELETED flag on the mail message. If false, the SEEN flag is set instead. As of Camel 2.10 you can override this configuration option by setting a header with the key delete to determine if the mail should be deleted or not.

false

Boolean

camel.component.mail.disconnect

Whether the consumer should disconnect after polling. If enabled this forces Camel to connect on each poll.

false

Boolean

camel.component.mail.enabled

Whether to enable auto configuration of the mail component. This is enabled by default.

Boolean

camel.component.mail.fetch-size

Sets the maximum number of messages to consume during a poll. This can be used to avoid overloading a mail server, if a mailbox folder contains a lot of messages. Default value of -1 means no fetch size and all messages will be consumed. Setting the value to 0 is a special corner case, where Camel will not consume any messages at all.

-1

Integer

camel.component.mail.folder-name

The folder to poll.

INBOX

String

camel.component.mail.from

The from email address

camel@localhost

String

camel.component.mail.handle-failed-message

If the mail consumer cannot retrieve a given mail message, then this option allows to handle the caused exception by the consumer’s error handler. By enable the bridge error handler on the consumer, then the Camel routing error handler can handle the exception instead. The default behavior would be the consumer throws an exception and no mails from the batch would be able to be routed by Camel.

false

Boolean

camel.component.mail.header-filter-strategy

To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. The option is a org.apache.camel.spi.HeaderFilterStrategy type.

String

camel.component.mail.ignore-unsupported-charset

Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead.

false

Boolean

camel.component.mail.ignore-uri-scheme

Option to let Camel ignore unsupported charset in the local JVM when sending mails. If the charset is unsupported then charset=XXX (where XXX represents the unsupported charset) is removed from the content-type and it relies on the platform default instead.

false

Boolean

camel.component.mail.java-mail-properties

Sets the java mail options. Will clear any default properties and only use the properties provided for this method. The option is a java.util.Properties type.

String

camel.component.mail.java-mail-sender

To use a custom org.apache.camel.component.mail.JavaMailSender for sending emails. The option is a org.apache.camel.component.mail.JavaMailSender type.

String

camel.component.mail.lazy-start-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

camel.component.mail.map-mail-message

Specifies whether Camel should map the received mail message to Camel body/headers/attachments. If set to true, the body of the mail message is mapped to the body of the Camel IN message, the mail headers are mapped to IN headers, and the attachments to Camel IN attachment message. If this option is set to false then the IN message contains a raw javax.mail.Message. You can retrieve this raw message by calling exchange.getIn().getBody(javax.mail.Message.class).

true

Boolean

camel.component.mail.mime-decode-headers

This option enables transparent MIME decoding and unfolding for mail headers.

false

Boolean

camel.component.mail.move-to

After processing a mail message, it can be moved to a mail folder with the given name. You can override this configuration value, with a header with the key moveTo, allowing you to move messages to folder names configured at runtime.

String

camel.component.mail.password

The password for login. See also setAuthenticator(MailAuthenticator).

String

camel.component.mail.peek

Will mark the javax.mail.Message as peeked before processing the mail message. This applies to IMAPMessage messages types only. By using peek the mail will not be eager marked as SEEN on the mail server, which allows us to rollback the mail message if there is an error processing in Camel.

true

Boolean

camel.component.mail.reply-to

The Reply-To recipients (the receivers of the response mail). Separate multiple email addresses with a comma.

String

camel.component.mail.session

Specifies the mail session that camel should use for all mail interactions. Useful in scenarios where mail sessions are created and managed by some other resource, such as a JavaEE container. When using a custom mail session, then the hostname and port from the mail session will be used (if configured on the session). The option is a javax.mail.Session type.

String

camel.component.mail.skip-failed-message

If the mail consumer cannot retrieve a given mail message, then this option allows to skip the message and move on to retrieve the next mail message. The default behavior would be the consumer throws an exception and no mails from the batch would be able to be routed by Camel.

false

Boolean

camel.component.mail.ssl-context-parameters

To configure security using SSLContextParameters. The option is a org.apache.camel.support.jsse.SSLContextParameters type.

String

camel.component.mail.subject

The Subject of the message being sent. Note: Setting the subject in the header takes precedence over this option.

String

camel.component.mail.to

Sets the To email address. Separate multiple email addresses with comma.

String

camel.component.mail.unseen

Whether to limit by unseen mails only.

true

Boolean

camel.component.mail.use-global-ssl-context-parameters

Enable usage of global SSL context parameters.

false

Boolean

camel.component.mail.use-inline-attachments

Whether to use disposition inline or attachment.

false

Boolean

camel.component.mail.username

The username for login. See also setAuthenticator(MailAuthenticator).

String

camel.dataformat.mime-multipart.binary-content

Defines whether the content of binary parts in the MIME multipart is binary (true) or Base-64 encoded (false) Default is false.

false

Boolean

camel.dataformat.mime-multipart.content-type-header

Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.

false

Boolean

camel.dataformat.mime-multipart.enabled

Whether to enable auto configuration of the mime-multipart data format. This is enabled by default.

Boolean

camel.dataformat.mime-multipart.headers-inline

Defines whether the MIME-Multipart headers are part of the message body (true) or are set as Camel headers (false). Default is false.

false

Boolean

camel.dataformat.mime-multipart.include-headers

A regex that defines which Camel headers are also included as MIME headers into the MIME multipart. This will only work if headersInline is set to true. Default is to include no headers

String

camel.dataformat.mime-multipart.multipart-sub-type

Specify the subtype of the MIME Multipart. Default is mixed.

mixed

String

camel.dataformat.mime-multipart.multipart-without-attachment

Defines whether a message without attachment is also marshaled into a MIME Multipart (with only one body part). Default is false.

false

Boolean