Package org.apache.camel.component.mail
Class MailConfiguration
java.lang.Object
org.apache.camel.component.mail.MailConfiguration
- All Implemented Interfaces:
Cloneable
Represents the configuration data for communicating over email
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
configureProtocol
(String protocol) The protocol for communicating with the mail servercopy()
Returns a copy of this configurationprotected JavaMailSender
createJavaMailSender
(org.apache.camel.CamelContext context) getBcc()
getCc()
long
int
getFrom()
getHost()
jakarta.mail.PasswordAuthentication
Returns the password authentication from the authenticator or from the parameters user and password.int
getPort()
jakarta.mail.Session
org.apache.camel.support.jsse.SSLContextParameters
getTo()
boolean
boolean
boolean
boolean
isDelete()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isPeek()
boolean
Is the used protocol to be secure or notboolean
boolean
boolean
isUnseen()
boolean
void
setAdditionalJavaMailProperties
(Properties additionalJavaMailProperties) Sets additional java mail properties, that will append/override any default properties that is set based on all the other options.void
setAlternativeBodyHeader
(String alternativeBodyHeader) Specifies the key to an IN message header that contains an alternative email body.void
setAttachmentsContentTransferEncodingResolver
(AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) To use a custom AttachmentsContentTransferEncodingResolver to resolve what content-type-encoding to use for attachments.void
setAuthenticator
(MailAuthenticator authenticator) The authenticator for login.void
Sets the BCC email address.void
Sets the CC email address.void
setCloseFolder
(boolean closeFolder) Whether the consumer should close the folder after polling.void
setConnectionTimeout
(int connectionTimeout) The connection timeout in milliseconds.void
setContentType
(String contentType) The mail message content type.void
After processing a mail message, it can be copied to a mail folder with the given name.void
setDebugMode
(boolean debugMode) Enable debug mode on the underlying mail framework.void
setDecodeFilename
(boolean decodeFilename) If set to true, the MimeUtility.decodeText method will be used to decode the filename.void
setDelete
(boolean delete) Deletes the messages after they have been processed.void
setDisconnect
(boolean disconnect) Whether the consumer should disconnect after polling.void
setFailOnDuplicateFileAttachment
(boolean failOnDuplicateFileAttachment) Whether to fail processing the mail if the mail message contains attachments with duplicate file names.void
setFetchSize
(int fetchSize) Sets the maximum number of messages to consume during a poll.void
setFolderName
(String folderName) The folder to poll.void
The from email addressvoid
setGenerateMissingAttachmentNames
(String generateMissingAttachmentNames) Set this to 'uuid' to set a UUID for the filename of the attachment if no filename was setvoid
setHandleDuplicateAttachmentNames
(String handleDuplicateAttachmentNames) Set the strategy to handle duplicate filenames of attachments never: attachments that have a filename which is already present in the attachments will be ignored unless failOnDuplicateFileAttachment is set to true.void
setHandleFailedMessage
(boolean handleFailedMessage) 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.void
The mail server host namevoid
setIgnoreUnsupportedCharset
(boolean ignoreUnsupportedCharset) Option to let Camel ignore unsupported charset in the local JVM when sending mails.void
setIgnoreUriScheme
(boolean ignoreUriScheme) Option to let Camel ignore unsupported charset in the local JVM when sending mails.void
setJavaMailProperties
(Properties javaMailProperties) Sets the java mail options.void
setJavaMailSender
(JavaMailSender javaMailSender) To use a customJavaMailSender
for sending emails.void
setMapMailMessage
(boolean mapMailMessage) Specifies whether Camel should map the received mail message to Camel body/headers/attachments.void
setMimeDecodeHeaders
(boolean mimeDecodeHeaders) This option enables transparent MIME decoding and unfolding for mail headers.void
After processing a mail message, it can be moved to a mail folder with the given name.void
setPassword
(String password) The password for login.void
setPeek
(boolean peek) Will mark the jakarta.mail.Message as peeked before processing the mail message.void
setPort
(int port) The port number of the mail servervoid
setReplyTo
(String replyTo) The Reply-To recipients (the receivers of the response mail).void
setSession
(jakarta.mail.Session session) Specifies the mail session that camel should use for all mail interactions.void
setSkipFailedMessage
(boolean skipFailedMessage) 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.void
setSslContextParameters
(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParameters.void
setSubject
(String subject) The Subject of the message being sent.void
Sets the To email address.void
setUnseen
(boolean unseen) Whether to limit by unseen mails only.void
setUseInlineAttachments
(boolean useInlineAttachments) Whether to use disposition inline or attachment.void
setUsername
(String username) The username for login.
-
Constructor Details
-
MailConfiguration
public MailConfiguration() -
MailConfiguration
public MailConfiguration(org.apache.camel.CamelContext context)
-
-
Method Details
-
copy
Returns a copy of this configuration -
configure
-
createJavaMailSender
-
getPasswordAuthentication
public jakarta.mail.PasswordAuthentication getPasswordAuthentication()Returns the password authentication from the authenticator or from the parameters user and password. -
isSecureProtocol
public boolean isSecureProtocol()Is the used protocol to be secure or not -
isStartTlsEnabled
public boolean isStartTlsEnabled() -
getMailStoreLogInformation
-
getJavaMailSender
-
setJavaMailSender
To use a customJavaMailSender
for sending emails. -
getHost
-
setHost
The mail server host name -
getJavaMailProperties
-
setJavaMailProperties
Sets the java mail options. Will clear any default properties and only use the properties provided for this method. -
getAdditionalJavaMailProperties
-
setAdditionalJavaMailProperties
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. -
getPassword
-
setPassword
The password for login. See alsosetAuthenticator(MailAuthenticator)
. -
getAuthenticator
-
setAuthenticator
The authenticator for login. If set then thepassword
andusername
are ignored. Can be used for tokens which can expire and therefore must be read dynamically. -
getSubject
-
setSubject
The Subject of the message being sent. Note: Setting the subject in the header takes precedence over this option. -
getPort
public int getPort() -
setPort
public void setPort(int port) The port number of the mail server -
getProtocol
-
configureProtocol
The protocol for communicating with the mail server -
getSession
public jakarta.mail.Session getSession() -
setSession
public void setSession(jakarta.mail.Session 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). -
getUsername
-
setUsername
The username for login. See alsosetAuthenticator(MailAuthenticator)
. -
getFrom
-
setFrom
The from email address -
isDelete
public boolean isDelete() -
setDelete
public void setDelete(boolean 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. -
isMapMailMessage
public boolean isMapMailMessage() -
setMapMailMessage
public void setMapMailMessage(boolean mapMailMessage) 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 jakarta.mail.Message. You can retrieve this raw message by calling exchange.getIn().getBody(jakarta.mail.Message.class). -
getFolderName
-
setFolderName
The folder to poll. -
isIgnoreUriScheme
public boolean isIgnoreUriScheme() -
setIgnoreUriScheme
public void setIgnoreUriScheme(boolean ignoreUriScheme) 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. -
isUnseen
public boolean isUnseen() -
setUnseen
public void setUnseen(boolean unseen) Whether to limit by unseen mails only. -
setTo
Sets the To email address. Separate multiple email addresses with comma. -
getTo
-
setCc
Sets the CC email address. Separate multiple email addresses with comma. -
getCc
-
setBcc
Sets the BCC email address. Separate multiple email addresses with comma. -
getBcc
-
getRecipients
-
getReplyTo
-
setReplyTo
The Reply-To recipients (the receivers of the response mail). Separate multiple email addresses with a comma. -
getFetchSize
public int getFetchSize() -
setFetchSize
public void setFetchSize(int fetchSize) 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. -
isDebugMode
public boolean isDebugMode() -
setDebugMode
public void setDebugMode(boolean debugMode) Enable debug mode on the underlying mail framework. The SUN Mail framework logs the debug messages to System.out by default. -
getConnectionTimeout
public long getConnectionTimeout() -
setConnectionTimeout
public void setConnectionTimeout(int connectionTimeout) The connection timeout in milliseconds. -
getContentType
-
setContentType
The mail message content type. Use text/html for HTML mails. -
getAlternativeBodyHeader
-
setAlternativeBodyHeader
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. -
isUseInlineAttachments
public boolean isUseInlineAttachments() -
setUseInlineAttachments
public void setUseInlineAttachments(boolean useInlineAttachments) Whether to use disposition inline or attachment. -
isIgnoreUnsupportedCharset
public boolean isIgnoreUnsupportedCharset() -
setIgnoreUnsupportedCharset
public void setIgnoreUnsupportedCharset(boolean ignoreUnsupportedCharset) 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. -
isDisconnect
public boolean isDisconnect() -
setDisconnect
public void setDisconnect(boolean disconnect) Whether the consumer should disconnect after polling. If enabled this forces Camel to connect on each poll. -
isCloseFolder
public boolean isCloseFolder() -
setCloseFolder
public void setCloseFolder(boolean closeFolder) 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. -
getSslContextParameters
public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters() -
setSslContextParameters
public void setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParameters. -
getCopyTo
-
getMoveTo
-
setMoveTo
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. -
setCopyTo
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. -
isPeek
public boolean isPeek() -
setPeek
public void setPeek(boolean peek) Will mark the jakarta.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. -
isSkipFailedMessage
public boolean isSkipFailedMessage() -
setSkipFailedMessage
public void setSkipFailedMessage(boolean skipFailedMessage) 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. -
isHandleFailedMessage
public boolean isHandleFailedMessage() -
setHandleFailedMessage
public void setHandleFailedMessage(boolean handleFailedMessage) 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. -
getAttachmentsContentTransferEncodingResolver
-
setAttachmentsContentTransferEncodingResolver
public void setAttachmentsContentTransferEncodingResolver(AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) To use a custom AttachmentsContentTransferEncodingResolver to resolve what content-type-encoding to use for attachments. -
setMimeDecodeHeaders
public void setMimeDecodeHeaders(boolean mimeDecodeHeaders) This option enables transparent MIME decoding and unfolding for mail headers. -
isMimeDecodeHeaders
public boolean isMimeDecodeHeaders() -
isDecodeFilename
public boolean isDecodeFilename() -
setDecodeFilename
public void setDecodeFilename(boolean decodeFilename) If set to true, the MimeUtility.decodeText method will be used to decode the filename. This is similar to setting JVM system property mail.mime.encodefilename. -
isFailOnDuplicateFileAttachment
public boolean isFailOnDuplicateFileAttachment() -
setFailOnDuplicateFileAttachment
public void setFailOnDuplicateFileAttachment(boolean failOnDuplicateFileAttachment) Whether to fail processing the mail if the mail message contains attachments with duplicate file names. If set to false, then the duplicate attachment is skipped and a WARN is logged. If set to true then an exception is thrown failing to process the mail message. -
getGenerateMissingAttachmentNames
-
setGenerateMissingAttachmentNames
Set this to 'uuid' to set a UUID for the filename of the attachment if no filename was set- Parameters:
generateMissingAttachmentNames
-
-
getHandleDuplicateAttachmentNames
-
setHandleDuplicateAttachmentNames
Set the strategy to handle duplicate filenames of attachments never: attachments that have a filename which is already present in the attachments will be ignored unless failOnDuplicateFileAttachment is set to true. uuidPrefix: this will prefix the duplicate attachment filenames each with a uuid and underscore (uuid_filename.fileextension). uuidSuffix: this will suffix the duplicate attachment filenames each with a underscore and uuid (filename_uuid.fileextension).- Parameters:
handleDuplicateAttachmentNames
-
-