2

我想使用 Spring Integration Mail 通过 IMAP 连接到 Microsoft Exchange 2010。我的问题是连接字符串的样子。

比方说:

domain=earth
user=jdoe
email=jon.doe@earth.com
Folder=inbox

据我所知,MS Exchange 仅支持 imap 进行连接。

我的 Spring 集成配置如下所示:

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

2 回答 2

2

现在发现了。它不必对连接字符串做任何事情。对于那些想要连接到 Exchange 的人,这里有一些提示。

这是我的配置:

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

通常 Exchange 使用带有 STARTTLS 连接的 Imap。

要执行 SSL 握手,您可以使用 InstallCert Java 程序: http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert。爪哇

于 2012-05-04T11:00:06.050 回答
0
  1. imaps:// 之后的第一个节点需要是服务器的 fqdn,而不是域(例如 email.earth.com)。
  2. 这里有一个关于交换凭证的常见问题http://www.oracle.com/technetwork/java/faq-135477.html
  3. IIRC,IMAP默认情况下在 Exchange 上启用,管理员必须启用它。
于 2012-05-02T15:39:25.660 回答