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

标签 java jakarta-mail

此代码旨在从 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 服务吗?

最佳答案

从表面上看,您正在尝试使用 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 进行设置。

关于java - 无法下载主题和发件人地址(rediff),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6816656/

相关文章:

java - Eclipselink 合并无法为更改的值生成 UPDATE 语句

java - 了解 Java 调试 SSL 消息

java - 在哪里可以找到所有可用的 Java 邮件属性?

javax.mail.SendFailedException

email - 多个收件人的 SMIME 解密

java - 处理 - 如何绘制 x/y 轴大于窗口宽度/高度的散点图

java - 使用 Antlr4 的翻译器

java - 使用 JPA 存储库的 Hibernate 获取配置文件

java - 如何在 JBoss 7 中从一台机器向 JMS 服务器发送消息并从另一台机器接收消息

java - 如何设置 NetBeans 引导类路径以包含 mail.jar?