I want to connect to Microsoft Exchange 2010 with IMAP using Spring Integration Mail. My question is how the connection string exactly look like.
Let's say:
domain=earth
user=jdoe
email=jon.doe@earth.com
Folder=inbox
As far as I know, MS Exchange only supports imaps for connection to.
My Spring integration config looks like this:
<util:properties id="javaMailProperties">
<prop key="mail.imaps.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imaps.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
</util:properties>
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imaps://earth/jdoe/jon.doe:jdoespw@example.mailhost.com/inbox" channel="recieveEmailChannel"
should-delete-messages="false" should-mark-messages-as-read="true"
auto-startup="true" java-mail-properties="javaMailProperties">
<int:poller fixed-delay="5"
time-unit="SECONDS" />
</mail:inbound-channel-adapter>
<int:channel id="recieveEmailChannel" />
<int:service-activator input-channel="recieveEmailChannel"
ref="mailReceiver" method="receive" />
<bean id="mailReceiver"
class="com.earth.MailReceiver" />
Found it out now. It doesn't has to do something with the connection string. For those who want to connect to Exchange, here some hints.
Here's my config:
<util:properties id="javaMailProperties">
<prop key="mail.imaps.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.starttls.enable">true</prop>
<prop key="mail.imaps.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
</util:properties>
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imap://<username>:<password>@<exchange-url>/INBOX" channel="recieveEmailChannel"
should-delete-messages="false" should-mark-messages-as-read="false"
auto-startup="true" java-mail-properties="javaMailProperties">
<int:poller fixed-delay="5"
time-unit="SECONDS" />
</mail:inbound-channel-adapter>
<int:channel id="recieveEmailChannel" />
<int:service-activator input-channel="recieveEmailChannel"
ref="reviewMailService" method="receive" />
Typically Exchange uses Imaps with STARTTLS connection.
To perform the SSL handshake, you can use the InstallCert Java program: http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java
- The first node after the imaps:// needs to be the fqdn of the server, not the domain (e.g. email.earth.com).
- There's a FAQ about exchange credentials here http://www.oracle.com/technetwork/java/faq-135477.html
- IIRC, IMAP is not enabled by default on Exchange and the admin has to enable it.
来源:https://stackoverflow.com/questions/10416142/connect-to-microsoft-exchange-server-with-spring-integration-mail