无法下载主题和发件人地址(rediff)

时间:2011-07-25 13:09:57

标签: java javamail

这是用于从rediff帐户获取主题和发件人地址的代码。但它没有这样做。

import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.swing.*;

class NewClass {
public static void main(String args[]) {
    Properties props = new Properties();
    props.put("mail.pop3.host" , "pop.rediffmail.com" );
    props.put("mail.pop3.user" , "username");
    // User SSL
    props.put("mail.pop3.socketFactory" , 110);
    props.put("mail.pop3.socketFactory.class" , "javax.net.ssl.SSLSocketFactory" );
    props.put("mail.pop3.port" , 110 );
    Session session = Session.getDefaultInstance(props , new Authenticator() {
        @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("username" , "password");
        }
    });

    try {
      Store store = session.getStore("pop3");
      store.connect("pop.rediffmail.com" , "username" , "password");
      Folder fldr = store.getFolder("Inbox");
      fldr.open(Folder.READ_WRITE);
      Message msgs[] = fldr.getMessages();
        for(int i = 0 ; i < msgs.length ; i++) {
            System.out.println(InternetAddress.toString(msgs[i].getFrom()) + "<-- FROM" + " " + msgs[i].getSubject() + "<---Subject");

        }
    } catch(Exception exc) {
        exc.printStackTrace();
    }
}

}

它在运行时提供以下异常:

javax.mail.MessagingException: Connect failed;
 nested exception is:
    javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at NewClass.main(NewClass.java:25)
  Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at sun.security.ssl.InputRecord.handleUnknownRecord(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:507)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:238)
    at com.sun.mail.pop3.Protocol.<init>(Protocol.java:107)
    at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:261)
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:206)
    ... 3 more

这是为什么? rediff甚至免费提供其他客户的pop3服务吗?

1 个答案:

答案 0 :(得分:2)

你试图通过它的外观使用SSL。端口110通常不用于SSL连接。


编辑:看起来rediff确实支持POP3:http://support.rediff.com/cgi-bin/support/printdetail.cgi?id=mail_1304.htm

删除你的SSL连接,你应该没事。


进一步编辑:看起来POP3是一项高级功能,因此可能无法在您的帐户中使用:http://support.rediff.com/cgi-bin/support/printdetail.cgi?id=mail_1301.htm

你需要联系rediff进行设置。