Connect to Microsoft Exchange Server with Spring Integration Mail

女生的网名这么多〃 提交于 2019-12-02 04:28:56

问题


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" />

回答1:


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




回答2:


  1. The first node after the imaps:// needs to be the fqdn of the server, not the domain (e.g. email.earth.com).
  2. There's a FAQ about exchange credentials here http://www.oracle.com/technetwork/java/faq-135477.html
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!