无法通过使用Javamail 1.6.2的代理服务器通过POP3连接到Outlook邮箱

问题描述 投票:-1回答:1

我正在尝试使用POP3 Javamail连接到Outlook邮箱。该邮箱在代理服务器上运行。我尝试将Javamail 1.6.2与以下配置一起使用:

    Properties props = new Properties();  
    props.put("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.pop3.socketFactory.fallback", "false");

    props.setProperty("mail.pop3.ssl.enable", "false");
    props.setProperty("mail.pop3.starttls.enable", "true"); 
    props.setProperty("mail.pop3.starttls.required", "true");

    props.setProperty("mail.pop3.proxy.host", "myproxy.server");
    props.setProperty("mail.pop3.proxy.port", "110");

    props.put("mail.pop3.ssl.trust", "*");

我在堆栈跟踪中收到以下错误:

com.sun.mail.util.MailConnectException: Couldn't connect to host, port: myproxy.server, 110; timeout -1; Using web proxy host, port: myproxy.server, 110 (java.net.ConnectException: connection through proxy myproxy.server:110 to myproxy.server:110 failed: +OK The Microsoft Exchange POP3 service is ready.)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:217)
    at javax.mail.Service.connect(Service.java:248)
    at javax.mail.Service.connect(Service.java:91)
    at com.zs.prp.services.impl.MailScannerServiceImpl.executeMailScanning(MailScannerServiceImpl.java:150)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy328.executeMailScanning(Unknown Source)
    at com.zs.prp.scheduler.MailScannerSchedulerJob.executeInternal(MailScannerSchedulerJob.java:34)
    at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:75)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.net.ConnectException: connection through proxy ZS-F5LBPOP.zs.local:110 to ZS-F5LBPOP.zs.local:110 failed: +OK The Microsoft Exchange POP3 service is ready.
    at com.sun.mail.util.SocketFetcher.proxyConnect(SocketFetcher.java:877)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:354)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:217)
    at com.sun.mail.pop3.Protocol.<init>(Protocol.java:118)
    at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:271)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:213)
    ... 20 more

尽管我正在设置mail.pop3.proxy.servermail.pop3.proxy.host属性仍然遇到此问题。有人可以帮我吗?

java javamail pop3
1个回答
0
投票

摆脱所有套接字出厂设置,you don't need them

您正在使用哪种代理服务器?您设置的属性是针对Web(http)代理服务器的。 Web代理服务器几乎可以肯定不在POP3端口110上运行;您需要Web代理服务器使用其他端口;问你的管理员用于正确的端口。

您还需要配置用于以下目的的POP3服务器的主机名:您希望代理服务器代表您连接。组mail.pop3.host属性。

如果没有帮助,请向我们提供更多详细信息,然后发布JavaMail debug output

© www.soinside.com 2019 - 2024. All rights reserved.