Package org.apache.camel.component.mail
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.
-
-
Constructor Summary
Constructors Constructor Description MailEndpoint()
MailEndpoint(String endpointUri)
MailEndpoint(String uri, MailComponent component, MailConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods 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 senderorg.apache.camel.Exchange
createExchange(javax.mail.Message message)
org.apache.camel.Producer
createProducer()
org.apache.camel.Producer
createProducer(JavaMailSender sender)
Creates a producer using the given senderMailBinding
getBinding()
MailConfiguration
getConfiguration()
ContentTypeResolver
getContentTypeResolver()
org.apache.camel.spi.HeaderFilterStrategy
getHeaderFilterStrategy()
org.apache.camel.spi.IdempotentRepository
getIdempotentRepository()
MailUidGenerator
getMailUidGenerator()
int
getMaxMessagesPerPoll()
MailBoxPostProcessAction
getPostProcessAction()
javax.mail.search.SearchTerm
getSearchTerm()
com.sun.mail.imap.SortTerm[]
getSortTerm()
boolean
isIdempotentRepositoryRemoveOnCommit()
void
setBinding(MailBinding binding)
Sets the binding used to convert from a Camel message to and from a Mail messagevoid
setConfiguration(MailConfiguration configuration)
Sets the Mail configurationvoid
setContentTypeResolver(ContentTypeResolver contentTypeResolver)
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 customHeaderFilterStrategy
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
setMailUidGenerator(MailUidGenerator mailUidGenerator)
A pluggableMailUidGenerator
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
setPostProcessAction(MailBoxPostProcessAction postProcessAction)
Refers to anMailBoxPostProcessAction
for doing post processing tasks on the mailbox once the normal processing ended.void
setSearchTerm(javax.mail.search.SearchTerm searchTerm)
Refers to aSearchTerm
which allows to filter mails based on search criteria such as subject, body, from, sent after a certain date etc.void
setSortTerm(com.sun.mail.imap.SortTerm[] sortTerm)
Sorting order for messages.-
Methods inherited from class org.apache.camel.support.ScheduledPollEndpoint
configureConsumer, configureProperties, configureScheduledPollConsumerProperties, doConfigureConsumer, doStart, doStop, 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, 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
-
-
-
-
Constructor Detail
-
MailEndpoint
public MailEndpoint()
-
MailEndpoint
public MailEndpoint(String endpointUri)
-
MailEndpoint
public MailEndpoint(String uri, MailComponent component, MailConfiguration configuration)
-
-
Method Detail
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.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 interfaceorg.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(javax.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 interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a customHeaderFilterStrategy
to filter headers.- Specified by:
setHeaderFilterStrategy
in interfaceorg.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 javax.mail.search.SearchTerm getSearchTerm()
-
setSearchTerm
public void setSearchTerm(javax.mail.search.SearchTerm searchTerm)
Refers to aSearchTerm
which allows to filter mails based on search criteria such as subject, body, from, sent after a certain date etc.
-
getSortTerm
public com.sun.mail.imap.SortTerm[] getSortTerm()
-
setSortTerm
public void setSortTerm(com.sun.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 anMailBoxPostProcessAction
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 pluggableMailUidGenerator
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 classorg.apache.camel.support.ScheduledPollEndpoint
-
-