Spring Integration

Class ImapMailReceiver

  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.mail.AbstractMailReceiver
          extended by org.springframework.integration.mail.ImapMailReceiver
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, NamedComponent, MailReceiver

public class ImapMailReceiver
extends AbstractMailReceiver

A MailReceiver implementation for receiving mail messages from a mail server that supports the IMAP protocol. In addition to the pollable AbstractMailReceiver.receive() method, the waitForNewMessages() method provides the option of blocking until new messages are available prior to calling AbstractMailReceiver.receive(). That option is only available if the server supports the idle command.

Arjen Poutsma, Mark Fisher, Oleg Zhurakousky, Gary Russell

Field Summary
Fields inherited from class org.springframework.integration.mail.AbstractMailReceiver
folderOpenMode, initialized, logger, SI_USER_FLAG
Constructor Summary
ImapMailReceiver(java.lang.String url)
Method Summary
 java.lang.Boolean isShouldMarkMessagesAsRead()
          Check if messages should be marked as read.
protected  javax.mail.Message[] searchForNewMessages()
          Retrieves new messages from this receiver's folder.
protected  void setAdditionalFlags(javax.mail.Message message)
          Optional method allowing you to set additional flags.
 void setShouldMarkMessagesAsRead(java.lang.Boolean shouldMarkMessagesAsRead)
          Specify if messages should be marked as read.
 void waitForNewMessages()
          This method is unique to the IMAP receiver and only works if IMAP IDLE is supported (see RFC 2177 for more detail).
Methods inherited from class org.springframework.integration.mail.AbstractMailReceiver
deleteMessages, destroy, fetchMessages, getFolder, onInit, openFolder, receive, setJavaMailAuthenticator, setJavaMailProperties, setMaxFetchSize, setProtocol, setSelectorExpression, setSession, setShouldDeleteMessages, shouldDeleteMessages, toString
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public ImapMailReceiver()


public ImapMailReceiver(java.lang.String url)
Method Detail


public java.lang.Boolean isShouldMarkMessagesAsRead()
Check if messages should be marked as read.


public void setShouldMarkMessagesAsRead(java.lang.Boolean shouldMarkMessagesAsRead)
Specify if messages should be marked as read.


public void waitForNewMessages()
                        throws javax.mail.MessagingException
This method is unique to the IMAP receiver and only works if IMAP IDLE is supported (see RFC 2177 for more detail).



protected javax.mail.Message[] searchForNewMessages()
                                             throws javax.mail.MessagingException
Retrieves new messages from this receiver's folder. This implementation creates a SearchTerm that searches for all messages in the folder that are RECENT, not ANSWERED, and not DELETED. The search term is used to search for new messages.

Specified by:
searchForNewMessages in class AbstractMailReceiver
the new messages
javax.mail.MessagingException - in case of JavaMail errors


protected void setAdditionalFlags(javax.mail.Message message)
                           throws javax.mail.MessagingException
Description copied from class: AbstractMailReceiver
Optional method allowing you to set additional flags. Currently only implemented in IMapMailReceiver.

setAdditionalFlags in class AbstractMailReceiver

Spring Integration