title: Spring Integration IMAP - Receive from multiple email accounts
body: <p>I've managed finally to use Spring's IMAP mechanism.</p>
  
  <p>Is it possible to actually receive emails from 3 different email accounts?</p>
  
  <p>My xml looks like this: </p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:mail="http://www.springframework.org/schema/integration/mail"
     xmlns:int="http://www.springframework.org/schema/integration"
     xmlns:util="http://www.springframework.org/schema/util"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/integration/mail
          http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"&gt;
  
  &lt;util:properties id="javaMailProperties"&gt;
      &lt;prop key="mail.imap.socketFactory.class"&gt;javax.net.ssl.SSLSocketFactory&lt;/prop&gt;
      &lt;prop key="mail.imap.socketFactory.fallback"&gt;false&lt;/prop&gt;
      &lt;prop key="mail.store.protocol"&gt;imaps&lt;/prop&gt;
      &lt;prop key="mail.debug"&gt;true&lt;/prop&gt;
      &lt;prop key="mail.imaps.ssl.trust"&gt;*&lt;/prop&gt;  &lt;!-- TODO change --&gt;
  &lt;/util:properties&gt;
  
  
  
  
  &lt;mail:inbound-channel-adapter id="imapAdapter"
                                    store-uri="imaps://avita.nir%40gmail.com:myPass@imap.gmail.com:993/inbox"                                  
                                    channel="recieveEmailChannel"                                         
                                    should-delete-messages="false"                                   
                                    should-mark-messages-as-read="true"                                     
                                    auto-startup="true"                                                                           
                                    java-mail-properties="javaMailProperties"&gt;
  
      &lt;int:poller fixed-delay="5" time-unit="SECONDS" /&gt;
  &lt;/mail:inbound-channel-adapter&gt;
  
  &lt;int:channel id="recieveEmailChannel"&gt;       
      &lt;int:interceptors&gt;
          &lt;int:wire-tap channel="logger"/&gt;
      &lt;/int:interceptors&gt;
  &lt;/int:channel&gt;
  
  &lt;int:logging-channel-adapter id="logger" level="DEBUG"/&gt;
  
  &lt;int:service-activator input-channel="recieveEmailChannel" ref="messageFactory" method="receive"/&gt;
  
  &lt;bean id="messageFactory" class="src.com.plantaware.service.factories.MessageFactory"&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>Is it possible to create another imapAdapter? is there any other way for multiple accounts? Is it even possible?</p>
  
  <p>Thanks again!</p>
  
  <p>Nir</p>