尝试连接到商店时出现以下异常。
2:56:26,020 ERROR [STDERR] javax.mail.MessagingException;
nested exception is:
java.io.IOException
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
12:56:26,021 ERROR [STDERR] at javax.mail.Service.connect(Service.java:275)
12:56:26,021 ERROR [STDERR] at javax.mail.Service.connect(Service.java:156)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorUtil.connect(Unknown Source)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorThread.connect(Unknown Source)
12:56:26,021 ERROR [STDERR] at com.invient.tickets.emailprocessor.EmailProcessorThread.run(Unknown Source)
12:56:26,021 ERROR [STDERR] Caused by: java.io.IOException
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:99)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.Response.<init>(Response.java:83)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
12:56:26,021 ERROR [STDERR] at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
12:56:26,021 ERROR [STDERR] at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
12:56:26,022 ERROR [STDERR] at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
12:56:26,022 ERROR [STDERR] ... 5 more
以下是我的属性列表
prop.put("mail.imap.host", "imap.gmail.com");
prop.put("mail.imap.user", "abc");
prop.put("mail.imap.ssl.enable", "true");
prop.put("mail.debug", "false");
prop.put("mail.imap.port", "993") ;
prop.put("mail.debug.quote", "false") ;
prop.put("mail.store.protocol", "imap") ;
当我执行以下操作时
Session session = Session.getInstance(prop);
Store store = session.getStore();
store.connect("imap.gmail.com", "userName", "passwd");
我得到了上述异常。 当我使用standalore程序尝试相同的代码时,它工作正常。我能够连接。但是,当我将代码放入我的JBoss时,它会抛出异常。
当我进入mail.jar的源代码时抛出异常,我可以看到当它尝试从Socket读取时会抛出异常。
先谢谢。
答案 0 :(得分:0)
使用以下属性可以实现连接。任何人都可以解释早期设置的问题是什么吗?
prop.put("mail.imap.host", "imap.gmail.com");
prop.put("mail.imap.user", "abc");
prop.put("mail.imap.ssl.enable", "true");
prop.put("mail.debug", "true");
prop.put("mail.imap.port", "993") ;
prop.put("mail.debug.quote", "false") ;
prop.put("mail.store.protocol", "imaps") ;
prop.put("mail.imap.socketFactory.class","javax.net.ssl.SSLSocketFactory");
prop.put("mail.imap.socketFactory.fallback", "false");