我正在使用 WSO2 ESB 4.7.0 版。我准备了使用电子邮件传输接收器的代理服务(基于示例 256)。在axis2.xml中,我在这几行中解锁了MailTransportListener:
<transportReceiver name="mailto" class="org.apache.axis2.transport.mail.MailTransportListener">
</transportReceiver>
这是我的代理服务。该服务使用的不是 POP3 协议而是 IMAP:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="MailProxyPublish"
transports="mailto"
statistics="enable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<clone>
<target sequence="somethingSequence10"/>
<target sequence="somethingSequence20"/>
</clone>
</inSequence>
</target>
<parameter name="transport.mail.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">20</parameter>
<parameter name="mail.imap.starttls.enable">false</parameter>
<parameter name="mail.imap.ssl.enable">false</parameter>
<parameter name="transport.mail.Folder">leader</parameter>
<parameter name="transport.mail.ContentType">text/plain</parameter>
<parameter name="transport.mail.MoveAfterProcess">PSX</parameter>
<parameter name="mail.imap.host">mail.yyyyy.biz</parameter>
<parameter name="transport.mail.Address">grzegorz.wwww@yyyyy.biz</parameter>
<parameter name="mail.imap.user">grzegorz.wwww.yyyyy</parameter>
<parameter name="transport.mail.Protocol">imap</parameter>
<parameter name="mail.imap.password">hs!01</parameter>
<description/>
</proxy>
当服务在日志 WSO2 ESB 中启动时,出现错误:
ERROR {org.apache.axis2.transport.mail.MailTransportListener} -
Error connecting to mail server for address :grzegorz.wwww@yyyyy.biz :: Unrecognized SSL message, plaintext connection? {org.apache.axis2.transport.mail.MailTransportListener}
javax.mail.MessagingException: Unrecognized SSL message, plaintext connection?;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:176)
at org.apache.axis2.transport.mail.MailTransportListener.checkMail(MailTransportListener.java:115)
at org.apache.axis2.transport.mail.MailTransportListener.poll(MailTransportListener.java:80)
at org.apache.axis2.transport.mail.MailTransportListener.poll(MailTransportListener.java:61)
at org.apache.axis2.transport.base.AbstractPollingTransportListener$1$1.run(AbstractPollingTransportListener.java:67)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:671)
at sun.security.ssl.InputRecord.read(InputRecord.java:504)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at com.sun.mail.iap.ResponseInputStream.read0(ResponseInputStream.java:81)
at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:67)
at com.sun.mail.iap.Response.<init>(Response.java:83)
at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:48)
at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:122)
at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:230)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:91)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
... 11 more
我的代理的参数 MailTransportListener 有什么问题?
我用 JavaMail 库(版本 1.4、1.4.7)编写了一个具有相同电子邮件参数的 Java 程序。它运作良好。这是代码:
package org.homelab;
import java.io.IOException;
import java.util.Properties;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import com.sun.mail.imap.IMAPStore;
public class EmailReceiveTest {
public static void main(String[] args) {
String mailHost = "mail.yyyyy.biz";
String mailStoreType = "imap";
String mailUser = "grzegorz.wwww.yyyyy;
String mailPassword = "hs!01";
receiveEmail(mailHost, mailStoreType, mailUser, mailPassword);
}
public static void receiveEmail(String host, String storeType, String user,
String password) {
//MailTransportListener
try {
Properties properties = new Properties();
properties.put("mail.imap.host", host);
//properties.put("mail.imap.port", 143);
//ERROR properties.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
//ERROR properties.put("mail.imap.socketFactory.fallback", "false");
//ERROR properties.put("mail.imap.socketFactory.port", 143);
Session emailSession = Session.getDefaultInstance(properties);
IMAPStore emailStore = (IMAPStore) emailSession.getStore(storeType);
emailStore.connect(user, password);
Folder emailFolder = emailStore.getFolder("leader");
emailFolder.open(Folder.READ_ONLY);
Message[] messages = emailFolder.getMessages();
for (int i = 0; i < messages.length; i++) {
Message message = messages[i];
System.out.println("==============================");
System.out.println("Email #" + (i + 1));
System.out.println("Subject: " + message.getSubject());
System.out.println("From: " + message.getFrom()[0]);
System.out.println("Body: ");
System.out.println( message.getContent().toString());
}
emailFolder.close(false);
emailStore.close();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
我重现了上述错误。当我在标有 //ERROR 的代码行中解锁时,也会发生同样的错误。
提前致谢, 格热戈兹