Package org.apache.camel.component.mail
Class MailConfiguration
- java.lang.Object
-
- org.apache.camel.component.mail.MailConfiguration
-
-
Constructor Summary
Constructors Constructor Description MailConfiguration()
MailConfiguration(org.apache.camel.CamelContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(URI uri)
void
configureProtocol(String protocol)
The protocol for communicating with the mail serverMailConfiguration
copy()
Returns a copy of this configurationprotected JavaMailSender
createJavaMailSender()
Properties
getAdditionalJavaMailProperties()
String
getAlternativeBodyHeader()
AttachmentsContentTransferEncodingResolver
getAttachmentsContentTransferEncodingResolver()
MailAuthenticator
getAuthenticator()
String
getBcc()
String
getCc()
long
getConnectionTimeout()
String
getContentType()
String
getCopyTo()
int
getFetchSize()
String
getFolderName()
String
getFrom()
String
getHost()
Properties
getJavaMailProperties()
JavaMailSender
getJavaMailSender()
String
getMailStoreLogInformation()
String
getMoveTo()
String
getPassword()
javax.mail.PasswordAuthentication
getPasswordAuthentication()
Returns the password authentication from the authenticator or from the parameters user and password.int
getPort()
String
getProtocol()
Map<javax.mail.Message.RecipientType,String>
getRecipients()
String
getReplyTo()
javax.mail.Session
getSession()
org.apache.camel.support.jsse.SSLContextParameters
getSslContextParameters()
String
getSubject()
String
getTo()
String
getUsername()
boolean
isCloseFolder()
boolean
isDebugMode()
boolean
isDecodeFilename()
boolean
isDelete()
boolean
isDisconnect()
boolean
isHandleFailedMessage()
boolean
isIgnoreUnsupportedCharset()
boolean
isIgnoreUriScheme()
boolean
isMapMailMessage()
boolean
isMimeDecodeHeaders()
boolean
isPeek()
boolean
isSecureProtocol()
Is the used protocol to be secure or notboolean
isSkipFailedMessage()
boolean
isStartTlsEnabled()
boolean
isUnseen()
boolean
isUseInlineAttachments()
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
setBcc(String address)
Sets the BCC email address.void
setCc(String address)
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
setCopyTo(String copyTo)
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
setFetchSize(int fetchSize)
Sets the maximum number of messages to consume during a poll.void
setFolderName(String folderName)
The folder to poll.void
setFrom(String from)
The from email addressvoid
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
setHost(String host)
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
setMoveTo(String moveTo)
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 javax.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(javax.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
setTo(String address)
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.
-
-
-
Method Detail
-
copy
public MailConfiguration copy()
Returns a copy of this configuration
-
configure
public void configure(URI uri)
-
createJavaMailSender
protected JavaMailSender createJavaMailSender()
-
getPasswordAuthentication
public javax.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
public String getMailStoreLogInformation()
-
getJavaMailSender
public JavaMailSender getJavaMailSender()
-
setJavaMailSender
public void setJavaMailSender(JavaMailSender javaMailSender)
To use a customJavaMailSender
for sending emails.
-
getHost
public String getHost()
-
setHost
public void setHost(String host)
The mail server host name
-
getJavaMailProperties
public Properties getJavaMailProperties()
-
setJavaMailProperties
public void setJavaMailProperties(Properties javaMailProperties)
Sets the java mail options. Will clear any default properties and only use the properties provided for this method.
-
getAdditionalJavaMailProperties
public Properties getAdditionalJavaMailProperties()
-
setAdditionalJavaMailProperties
public 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. This is useful if you need to add some special options but want to keep the others as is.
-
getPassword
public String getPassword()
-
setPassword
public void setPassword(String password)
The password for login. See alsosetAuthenticator(MailAuthenticator)
.
-
getAuthenticator
public MailAuthenticator getAuthenticator()
-
setAuthenticator
public void setAuthenticator(MailAuthenticator authenticator)
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
public String getSubject()
-
setSubject
public void setSubject(String subject)
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
public String getProtocol()
-
configureProtocol
public void configureProtocol(String protocol)
The protocol for communicating with the mail server
-
getSession
public javax.mail.Session getSession()
-
setSession
public void setSession(javax.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
public String getUsername()
-
setUsername
public void setUsername(String username)
The username for login. See alsosetAuthenticator(MailAuthenticator)
.
-
getFrom
public String getFrom()
-
setFrom
public void setFrom(String from)
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 javax.mail.Message. You can retrieve this raw message by calling exchange.getIn().getBody(javax.mail.Message.class).
-
getFolderName
public String getFolderName()
-
setFolderName
public void setFolderName(String folderName)
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
public void setTo(String address)
Sets the To email address. Separate multiple email addresses with comma.
-
getTo
public String getTo()
-
setCc
public void setCc(String address)
Sets the CC email address. Separate multiple email addresses with comma.
-
getCc
public String getCc()
-
setBcc
public void setBcc(String address)
Sets the BCC email address. Separate multiple email addresses with comma.
-
getBcc
public String getBcc()
-
getReplyTo
public String getReplyTo()
-
setReplyTo
public void setReplyTo(String replyTo)
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
public String getContentType()
-
setContentType
public void setContentType(String contentType)
The mail message content type. Use text/html for HTML mails.
-
getAlternativeBodyHeader
public String getAlternativeBodyHeader()
-
setAlternativeBodyHeader
public void setAlternativeBodyHeader(String alternativeBodyHeader)
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
public String getCopyTo()
-
getMoveTo
public String getMoveTo()
-
setMoveTo
public void setMoveTo(String moveTo)
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
public void setCopyTo(String copyTo)
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 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.
-
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
public AttachmentsContentTransferEncodingResolver 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.
-
-