gpt4 book ai didi

Java imap 连接存储带和不带 ssl

转载 作者:行者123 更新时间:2023-11-30 10:46:58 25 4
gpt4 key购买 nike

我正在尝试连接到基于用户服务器的 imap 商店。例如,我有多个服务器,例如 143 个带 ssl 的服务器和 993 个不带 ssl 的服务器。当我尝试连接到 143 ssl 服务器时,它说是普通连接。有什么办法可以像这样连接到商店吗?

java中除了javamail还有其他IMAP吗?

下面是一些代码->

Properties props = System.getProperties();
String imapProtocol = server.getImapSsl() != null && server.getImapSsl() == true ? "imaps" : "imap";
props.put("mail.store.protocol", imapProtocol);
props.put("mail." + imapProtocol + ".port", server.getImapPort());
props.put("mail." + imapProtocol + ".host", server.getImapHost());

javax.mail.Session mailSession = javax.mail.Session.getInstance(props, null);
Store store = mailSession.getStore();
store.connect(server.getImapHost(), server.getImapPort(), username, password);

更新(调试)->

DEBUG IMAP: enable STARTTLS
DEBUG IMAP: closeFoldersOnStoreFailure
DEBUG IMAP: trying to connect to host "imap.itheme.mn", port 143, isSSL false
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE NAMESPACE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: LOGIN
DEBUG IMAP: protocolConnect login, host=imap.somemail.mn, user=zolboo@itheme.mn, password=<non-null>
A0 STARTTLS
A0 OK Begin TLS negotiation now.
A1 CAPABILITY
* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE NAMESPACE AUTH=PLAIN AUTH=LOGIN
A1 OK Pre-login capabilities listed, post-login capabilities have more.
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: LOGIN
DEBUG IMAP: AUTHENTICATE LOGIN command trace suppressed
DEBUG IMAP: AUTHENTICATE LOGIN command result: A2 NO [AUTHENTICATIONFAILED] Authentication failed.

最佳答案

你得到的端口号是倒过来的。 143 是纯文本。

关于Java imap 连接存储带和不带 ssl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36298207/

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