gpt4 book ai didi

Java/JavaMail : Null pointer exception when trying to create a folder to fetch E-Mails (GMAIL/POP3)

转载 作者:行者123 更新时间:2023-12-02 04:31:10 27 4
gpt4 key购买 nike

一切正常,包括身份验证,但是当我到达创建文件夹的步骤时,程序崩溃了。

我尝试过切换到 SMTP,但没有成功,甚至不知道 SMTP 是什么,我尝试过其他 Gmail 帐户,我尝试删除行 properties.put("mail.pop3.starttls.enable", "true") 和我尝试从 pop3pop3s 中删除 3。

    private static void createProperties() {
// Create properties field.

Properties properties = new Properties();
properties.put("mail.pop3.host", host);
properties.put("mail.store.protocol", "pop3s");
properties.put("mail.pop3.port", "995");
//properties.put("mail.pop3.starttls.enable", "true");

emailSession = Session.getDefaultInstance(properties, null);
}

private static void createStore() throws MessagingException {
// Create the POP3 store object and connect with the POP server.

Store store = emailSession.getStore("pop3s");
store.connect(host, user, password);
}

private static void createFolder() throws MessagingException {
// Create the folder object and open it.

Folder emailFolder = store.getFolder("INBOX"); // Error here
emailFolder.open(Folder.READ_ONLY);
}

我希望收到一些格式良好的电子邮件。我收到以下错误:

DEBUG POP3: server doesn't support TOP, disabling it 
Exception in thread "main" java.lang.NullPointerException
at GetMail.createFolder(GetMail.java:60)
at GetMail.main(GetMail.java:33)```

最佳答案

POP3协议(protocol)只支持一个文件夹——收件箱。请改用 IMAP。

关于Java/JavaMail : Null pointer exception when trying to create a folder to fetch E-Mails (GMAIL/POP3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56584261/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com