Class MailConfiguration

  • All Implemented Interfaces:
    Cloneable

    @UriParams
    public class MailConfiguration
    extends Object
    implements Cloneable
    Represents the configuration data for communicating over email
    • Constructor Detail

      • MailConfiguration

        public MailConfiguration()
      • MailConfiguration

        public MailConfiguration​(org.apache.camel.CamelContext context)
    • Method Detail

      • configure

        public void configure​(URI uri)
      • createJavaMailSender

        protected JavaMailSender createJavaMailSender​(org.apache.camel.CamelContext context)
      • 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()
      • 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()
      • setAuthenticator

        public void setAuthenticator​(MailAuthenticator 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.
      • 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()
      • 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()
      • getRecipients

        public Map<javax.mail.Message.RecipientType,​String> getRecipients()
      • 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.

      • 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

        public String getGenerateMissingAttachmentNames()
      • setGenerateMissingAttachmentNames

        public void setGenerateMissingAttachmentNames​(String generateMissingAttachmentNames)
        Set this to 'uuid' to set a UUID for the filename of the attachment if no filename was set
        Parameters:
        generateMissingAttachmentNames -
      • getHandleDuplicateAttachmentNames

        public String getHandleDuplicateAttachmentNames()
      • setHandleDuplicateAttachmentNames

        public void 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. 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 -