Reputation: 1095
I have a Spring Integration process created to process email messages programatically. It works fine from my IDE, but fails when I deploy it to our Tomcat Unix server. I'm running JDK 1.6.0.4, Tomcat 7.0.29, Grails 2.0.4, Spring Integration 2.1.3, and JavaMail 1.4.5. I'm trying to figure out how to get proxy settings configured so that I can run this. I've seen posts from 2010 saying that it's not possible, but it looks like there are JavaMail properties for it now.
I did try setting -DsocksProxyHost=myproxy.mycompany.com
in the Tomcat setenv.sh
, but my app failed before it even got to the mail part because it then couldn't access internal sites (like our datatbase connection)
I've looked at the JavaMail API - FAQ and I think I'm setting things up correctly, but it keeps timing out.
Has anyone successfully setup email proxies for Spring Integration processes?
Snippet from my Spring Integration XML file:
<util:properties id="javaMailProperties">
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
<prop key="mail.smtp.socks.host">socksproxy.mycompany.com</prop>
<prop key="mail.smtp.socks.port">1080</prop>
<prop key="mail.imap.socks.host">socksproxy.mycompany.com</prop>
<prop key="mail.imap.socks.port">1080</prop>
</util:properties>
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imaps://myEmailAddress:[email protected]/INBOX"
java-mail-properties="javaMailProperties"
channel="receiveEmailChannel"
should-delete-messages="false"
should-mark-messages-as-read="true"
auto-startup="true">
<int:poller max-messages-per-poll="1" fixed-rate="15" time-unit="SECONDS">
</int:poller>
</mail:inbound-channel-adapter>
Based on Bill Shannon's response, I updated my javaMailProperties
to the snippet below and everything is working as expected.
<util:properties id="javaMailProperties">
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.imap.ssl.enable">true</prop>
<prop key="mail.debug">true</prop>
<prop key="mail.imaps.socks.host">socksproxy.mycompany.com</prop>
<prop key="mail.imaps.socks.port">1080</prop>
</util:properties>
I think it's important to point out the fine print from the JavaDocs...
Note that if you're using the "imaps" protocol to access IMAP over SSL, all the properties would be named "mail.imaps.*"
Upvotes: 2
Views: 2632
Reputation: 29971
There's at least two problems...
First, you don't need the socket factory settings.
Second, you're using the imaps
protocol, but setting properties for the imap
protocol.
Either set mail.store.protocol
to imap
and set mail.imap.ssl.enable
to true
, or change all the mail.imap.*
properties to mail.imaps.*
properties.
Upvotes: 3