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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidvoidconfigureProtocol(String protocol) The protocol for communicating with the mail servercopy()Returns a copy of this configurationprotected JavaMailSendercreateJavaMailSender(org.apache.camel.CamelContext context) getBcc()getCc()longintgetFrom()getHost()jakarta.mail.PasswordAuthenticationReturns the password authentication from the authenticator or from the parameters user and password.intgetPort()jakarta.mail.Sessionorg.apache.camel.support.jsse.SSLContextParametersgetTo()booleanbooleanbooleanbooleanisDelete()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisPeek()booleanIs the used protocol to be secure or notbooleanbooleanbooleanisUnseen()booleanvoidsetAdditionalJavaMailProperties(Properties additionalJavaMailProperties) Sets additional java mail properties, that will append/override any default properties that are set based on all the other options.voidsetAlternativeBodyHeader(String alternativeBodyHeader) Specifies the key to an IN message header that contains an alternative email body.voidsetAttachmentsContentTransferEncodingResolver(AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) To use a custom AttachmentsContentTransferEncodingResolver to resolve what content-type-encoding to use for attachments.voidsetAuthenticator(MailAuthenticator authenticator) The authenticator for login.voidSets the BCC email address.voidSets the CC email address.voidsetCloseFolder(boolean closeFolder) Whether the consumer should close the folder after polling.voidsetConnectionTimeout(int connectionTimeout) The connection timeout in milliseconds.voidsetContentType(String contentType) The mail message content type.voidAfter processing a mail message, it can be copied to a mail folder with the given name.voidsetDebugMode(boolean debugMode) Enable debug mode on the underlying mail framework.voidsetDecodeFilename(boolean decodeFilename) If set to true, the MimeUtility.decodeText method will be used to decode the filename.voidsetDelete(boolean delete) Deletes the messages after they have been processed.voidsetDisconnect(boolean disconnect) Whether the consumer should disconnect after polling.voidsetFailOnDuplicateFileAttachment(boolean failOnDuplicateFileAttachment) Whether to fail processing the mail if the mail message contains attachments with duplicate file names.voidsetFetchSize(int fetchSize) Sets the maximum number of messages to consume during a poll.voidsetFolderName(String folderName) The folder to poll.voidThe from email addressvoidsetGenerateMissingAttachmentNames(String generateMissingAttachmentNames) Set this to 'uuid' to set a UUID for the filename of the attachment if no filename was setvoidsetHandleDuplicateAttachmentNames(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.voidsetHandleFailedMessage(boolean handleFailedMessage) If the mail consumer cannot retrieve a given mail message, then this option allows handling the caused exception by the consumer's error handler.voidThe mail server host namevoidsetIgnoreUnsupportedCharset(boolean ignoreUnsupportedCharset) Option to let Camel ignore unsupported charset in the local JVM when sending mails.voidsetIgnoreUriScheme(boolean ignoreUriScheme) Option to let Camel ignore unsupported charset in the local JVM when sending mails.voidsetJavaMailProperties(Properties javaMailProperties) Sets the java mail options.voidsetJavaMailSender(JavaMailSender javaMailSender) To use a customJavaMailSenderfor sending emails.voidsetMapMailMessage(boolean mapMailMessage) Specifies whether Camel should map the received mail message to Camel body/headers/attachments.voidsetMimeDecodeHeaders(boolean mimeDecodeHeaders) This option enables transparent MIME decoding and unfolding for mail headers.voidAfter processing a mail message, it can be moved to a mail folder with the given name.voidsetPassword(String password) The password for login.voidsetPeek(boolean peek) Will mark the jakarta.mail.Message as peeked before processing the mail message.voidsetPort(int port) The port number of the mail servervoidsetReplyTo(String replyTo) The Reply-To recipients (the receivers of the response mail).voidsetSession(jakarta.mail.Session session) Specifies the mail session that camel should use for all mail interactions.voidsetSkipFailedMessage(boolean skipFailedMessage) If the mail consumer cannot retrieve a given mail message, then this option allows skipping the message and move on to retrieve the next mail message.voidsetSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParameters.voidsetSubject(String subject) The Subject of the message being sent.voidSets the destination email address.voidsetUnseen(boolean unseen) Whether to limit by unseen mails only.voidsetUseInlineAttachments(boolean useInlineAttachments) Whether to use disposition inline or attachment.voidsetUsername(String username) The username for login.
- 
Constructor Details- 
MailConfigurationpublic MailConfiguration()
- 
MailConfigurationpublic MailConfiguration(org.apache.camel.CamelContext context) 
 
- 
- 
Method Details- 
copyReturns a copy of this configuration
- 
configure
- 
createJavaMailSender
- 
getPasswordAuthenticationpublic jakarta.mail.PasswordAuthentication getPasswordAuthentication()Returns the password authentication from the authenticator or from the parameters user and password.
- 
isSecureProtocolpublic boolean isSecureProtocol()Is the used protocol to be secure or not
- 
isStartTlsEnabledpublic boolean isStartTlsEnabled()
- 
getMailStoreLogInformation
- 
getJavaMailSender
- 
setJavaMailSenderTo use a customJavaMailSenderfor sending emails.
- 
getHost
- 
setHostThe mail server host name
- 
getJavaMailProperties
- 
setJavaMailPropertiesSets the java mail options. Will clear any default properties and only use the properties provided for this method.
- 
getAdditionalJavaMailProperties
- 
setAdditionalJavaMailPropertiesSets additional java mail properties, that will append/override any default properties that are 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
- 
setPasswordThe password for login. See alsosetAuthenticator(MailAuthenticator).
- 
getAuthenticator
- 
setAuthenticatorThe authenticator for login. If set then thepasswordandusernameare ignored. It can be used for tokens which can expire and therefore must be read dynamically.
- 
getSubject
- 
setSubjectThe Subject of the message being sent. Note: Setting the subject in the header takes precedence over this option.
- 
getPortpublic int getPort()
- 
setPortpublic void setPort(int port) The port number of the mail server
- 
getProtocol
- 
configureProtocolThe protocol for communicating with the mail server
- 
getSessionpublic jakarta.mail.Session getSession()
- 
setSessionpublic 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
- 
setUsernameThe username for login. See alsosetAuthenticator(MailAuthenticator).
- 
getFrom
- 
setFromThe from email address
- 
isDeletepublic boolean isDelete()
- 
setDeletepublic 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. You can override this configuration option by setting a header with the key delete to determine if the mail should be deleted or not.
- 
isMapMailMessagepublic boolean isMapMailMessage()
- 
setMapMailMessagepublic 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
- 
setFolderNameThe folder to poll.
- 
isIgnoreUriSchemepublic boolean isIgnoreUriScheme()
- 
setIgnoreUriSchemepublic 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.
- 
isUnseenpublic boolean isUnseen()
- 
setUnseenpublic void setUnseen(boolean unseen) Whether to limit by unseen mails only.
- 
setToSets the destination email address. Separate multiple email addresses with comma.
- 
getTo
- 
setCcSets the CC email address. Separate multiple email addresses with comma.
- 
getCc
- 
setBccSets the BCC email address. Separate multiple email addresses with comma.
- 
getBcc
- 
getRecipients
- 
getReplyTo
- 
setReplyToThe Reply-To recipients (the receivers of the response mail). Separate multiple email addresses with a comma.
- 
getFetchSizepublic int getFetchSize()
- 
setFetchSizepublic 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. The 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.
- 
isDebugModepublic boolean isDebugMode()
- 
setDebugModepublic 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.
- 
getConnectionTimeoutpublic long getConnectionTimeout()
- 
setConnectionTimeoutpublic void setConnectionTimeout(int connectionTimeout) The connection timeout in milliseconds.
- 
getContentType
- 
setContentTypeThe mail message content type. Use text/html for HTML mails.
- 
getAlternativeBodyHeader
- 
setAlternativeBodyHeaderSpecifies 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.
- 
isUseInlineAttachmentspublic boolean isUseInlineAttachments()
- 
setUseInlineAttachmentspublic void setUseInlineAttachments(boolean useInlineAttachments) Whether to use disposition inline or attachment.
- 
isIgnoreUnsupportedCharsetpublic boolean isIgnoreUnsupportedCharset()
- 
setIgnoreUnsupportedCharsetpublic 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.
- 
isDisconnectpublic boolean isDisconnect()
- 
setDisconnectpublic void setDisconnect(boolean disconnect) Whether the consumer should disconnect after polling. If enabled, this forces Camel to connect on each poll.
- 
isCloseFolderpublic boolean isCloseFolder()
- 
setCloseFolderpublic 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 keeps the folder open between polls.
- 
getSslContextParameterspublic org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
- 
setSslContextParameterspublic void setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParameters.
- 
getCopyTo
- 
getMoveTo
- 
setMoveToAfter 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.
- 
setCopyToAfter 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.
- 
isPeekpublic boolean isPeek()
- 
setPeekpublic 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 eagerly marked as SEEN on the mail server, which allows us to roll back the mail message if there is a processing error in Camel.
- 
isSkipFailedMessagepublic boolean isSkipFailedMessage()
- 
setSkipFailedMessagepublic void setSkipFailedMessage(boolean skipFailedMessage) If the mail consumer cannot retrieve a given mail message, then this option allows skipping 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.
- 
isHandleFailedMessagepublic boolean isHandleFailedMessage()
- 
setHandleFailedMessagepublic void setHandleFailedMessage(boolean handleFailedMessage) If the mail consumer cannot retrieve a given mail message, then this option allows handling the caused exception by the consumer's error handler. By enabling 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
- 
setAttachmentsContentTransferEncodingResolverpublic void setAttachmentsContentTransferEncodingResolver(AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) To use a custom AttachmentsContentTransferEncodingResolver to resolve what content-type-encoding to use for attachments.
- 
setMimeDecodeHeaderspublic void setMimeDecodeHeaders(boolean mimeDecodeHeaders) This option enables transparent MIME decoding and unfolding for mail headers.
- 
isMimeDecodeHeaderspublic boolean isMimeDecodeHeaders()
- 
isDecodeFilenamepublic boolean isDecodeFilename()
- 
setDecodeFilenamepublic 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.
- 
isFailOnDuplicateFileAttachmentpublic boolean isFailOnDuplicateFileAttachment()
- 
setFailOnDuplicateFileAttachmentpublic 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
- 
setGenerateMissingAttachmentNamesSet this to 'uuid' to set a UUID for the filename of the attachment if no filename was set- Parameters:
- generateMissingAttachmentNames-
 
- 
getHandleDuplicateAttachmentNames
- 
setHandleDuplicateAttachmentNamesSet 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 an uuid and underscore (uuid_filename.fileextension). uuidSuffix: this will suffix the duplicate attachment filenames each with an underscore and uuid (filename_uuid.fileextension).- Parameters:
- handleDuplicateAttachmentNames-
 
 
-