Class MailEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.support.ScheduledPollEndpoint
org.apache.camel.component.mail.MailEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.spi.HeaderFilterStrategyAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@UriEndpoint(firstVersion="1.0.0", scheme="imap,imaps,pop3,pop3s,smtp,smtps", title="IMAP,IMAPS,POP3,POP3S,SMTP,SMTPS", syntax="imap:host:port", alternativeSyntax="imap:username:password@host:port", category=MAIL, headersClass=MailConstants.class) public class MailEndpoint extends org.apache.camel.support.ScheduledPollEndpoint implements org.apache.camel.spi.HeaderFilterStrategyAware
Send and receive emails using imap, pop3 and smtp protocols.
  • Field Summary

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    MailEndpoint(String endpointUri)
     
    MailEndpoint(String uri, MailComponent component, MailConfiguration configuration)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor, JavaMailSender sender)
    Creates a consumer using the given processor and sender
    org.apache.camel.Exchange
    createExchange(jakarta.mail.Message message)
     
    org.apache.camel.Producer
     
    org.apache.camel.Producer
    Creates a producer using the given sender
     
     
     
    org.apache.camel.spi.HeaderFilterStrategy
     
    org.apache.camel.spi.IdempotentRepository
     
     
    int
     
     
    jakarta.mail.search.SearchTerm
     
    org.eclipse.angus.mail.imap.SortTerm[]
     
    boolean
     
    void
    Sets the binding used to convert from a Camel message to and from a Mail message
    void
    Sets the Mail configuration
    void
    Resolver to determine Content-Type for file attachments.
    void
    setDelay(long delay)
    Milliseconds before the next poll.
    void
    setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
    To use a custom HeaderFilterStrategy to filter headers.
    void
    setIdempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository)
    A pluggable repository org.apache.camel.spi.IdempotentRepository which allows to cluster consuming from the same mailbox, and let the repository coordinate whether a mail message is valid for the consumer to process.
    void
    setIdempotentRepositoryRemoveOnCommit(boolean idempotentRepositoryRemoveOnCommit)
    When using idempotent repository, then when the mail message has been successfully processed and is committed, should the message id be removed from the idempotent repository (default) or be kept in the repository.
    void
    A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message.
    void
    setMaxMessagesPerPoll(int maxMessagesPerPoll)
    Specifies the maximum number of messages to gather per poll.
    void
    Refers to an MailBoxPostProcessAction for doing post processing tasks on the mailbox once the normal processing ended.
    void
    setSearchTerm(jakarta.mail.search.SearchTerm searchTerm)
    Refers to a SearchTerm which allows to filter mails based on search criteria such as subject, body, from, sent after a certain date etc.
    void
    setSortTerm(org.eclipse.angus.mail.imap.SortTerm[] sortTerm)
    Sorting order for messages.

    Methods inherited from class org.apache.camel.support.ScheduledPollEndpoint

    configureConsumer, configureProperties, configureScheduledPollConsumerProperties, doConfigureConsumer, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDefaultDelay, getDelay, getInitialDelay, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isGreedy, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay

    Methods inherited from class org.apache.camel.support.DefaultEndpoint

    configureExchange, configurePollingConsumer, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.Endpoint

    getEndpointBaseUri, isSingletonProducer

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

  • Method Details

    • createProducer

      public org.apache.camel.Producer createProducer() throws Exception
      Specified by:
      createProducer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • createProducer

      public org.apache.camel.Producer createProducer(JavaMailSender sender)
      Creates a producer using the given sender
    • createConsumer

      public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
      Specified by:
      createConsumer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • createConsumer

      public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor, JavaMailSender sender) throws Exception
      Creates a consumer using the given processor and sender
      Throws:
      Exception
    • createExchange

      public org.apache.camel.Exchange createExchange(jakarta.mail.Message message)
    • getBinding

      public MailBinding getBinding()
    • setBinding

      public void setBinding(MailBinding binding)
      Sets the binding used to convert from a Camel message to and from a Mail message
    • getConfiguration

      public MailConfiguration getConfiguration()
    • setConfiguration

      public void setConfiguration(MailConfiguration configuration)
      Sets the Mail configuration
    • getHeaderFilterStrategy

      public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
      Specified by:
      getHeaderFilterStrategy in interface org.apache.camel.spi.HeaderFilterStrategyAware
    • setHeaderFilterStrategy

      public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
      To use a custom HeaderFilterStrategy to filter headers.
      Specified by:
      setHeaderFilterStrategy in interface org.apache.camel.spi.HeaderFilterStrategyAware
    • getContentTypeResolver

      public ContentTypeResolver getContentTypeResolver()
    • setContentTypeResolver

      public void setContentTypeResolver(ContentTypeResolver contentTypeResolver)
      Resolver to determine Content-Type for file attachments.
    • getMaxMessagesPerPoll

      public int getMaxMessagesPerPoll()
    • setMaxMessagesPerPoll

      public void setMaxMessagesPerPoll(int maxMessagesPerPoll)
      Specifies the maximum number of messages to gather per poll. By default, no maximum is set. Can be used to set a limit of e.g. 1000 to avoid downloading thousands of files when the server starts up. Set a value of 0 or negative to disable this option.
    • getSearchTerm

      public jakarta.mail.search.SearchTerm getSearchTerm()
    • setSearchTerm

      public void setSearchTerm(jakarta.mail.search.SearchTerm searchTerm)
      Refers to a SearchTerm which allows to filter mails based on search criteria such as subject, body, from, sent after a certain date etc.
    • getSortTerm

      public org.eclipse.angus.mail.imap.SortTerm[] getSortTerm()
    • setSortTerm

      public void setSortTerm(org.eclipse.angus.mail.imap.SortTerm[] sortTerm)
      Sorting order for messages. Only natively supported for IMAP. Emulated to some degree when using POP3 or when IMAP server does not have the SORT capability.
    • getPostProcessAction

      public MailBoxPostProcessAction getPostProcessAction()
    • setPostProcessAction

      public void setPostProcessAction(MailBoxPostProcessAction postProcessAction)
      Refers to an MailBoxPostProcessAction for doing post processing tasks on the mailbox once the normal processing ended.
    • getIdempotentRepository

      public org.apache.camel.spi.IdempotentRepository getIdempotentRepository()
    • setIdempotentRepository

      public void setIdempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository)
      A pluggable repository org.apache.camel.spi.IdempotentRepository which allows to cluster consuming from the same mailbox, and let the repository coordinate whether a mail message is valid for the consumer to process.

      By default no repository is in use.

    • isIdempotentRepositoryRemoveOnCommit

      public boolean isIdempotentRepositoryRemoveOnCommit()
    • setIdempotentRepositoryRemoveOnCommit

      public void setIdempotentRepositoryRemoveOnCommit(boolean idempotentRepositoryRemoveOnCommit)
      When using idempotent repository, then when the mail message has been successfully processed and is committed, should the message id be removed from the idempotent repository (default) or be kept in the repository.

      By default its assumed the message id is unique and has no value to be kept in the repository, because the mail message will be marked as seen/moved or deleted to prevent it from being consumed again. And therefore having the message id stored in the idempotent repository has little value. However this option allows to store the message id, for whatever reason you may have.

    • getMailUidGenerator

      public MailUidGenerator getMailUidGenerator()
    • setMailUidGenerator

      public void setMailUidGenerator(MailUidGenerator mailUidGenerator)
      A pluggable MailUidGenerator that allows to use custom logic to generate UUID of the mail message.
    • setDelay

      public void setDelay(long delay)
      Milliseconds before the next poll.
      Overrides:
      setDelay in class org.apache.camel.support.ScheduledPollEndpoint