gpt4 book ai didi

java - 无法从 Yahoo IMAP 帐户删除邮件

转载 作者:行者123 更新时间:2023-12-01 14:04:52 25 4
gpt4 key购买 nike

我的要求是我想从我的 Yahoo 帐户中删除邮件,所有代码在我的 Gmail 帐户上运行良好。

下面是删除代码-

   Message msg[] = inbox.getMessages();
inbox.setFlags(msg, new Flags(Flags.Flag.DELETED), true);

执行上述代码行后,我不会关闭文件夹。由于我在设置 DELETED 标志后无法关闭文件夹,因为我的代码正在并行运行以删除多个文件夹的多条消息。

下面是 Gmail 和 Yahoo 删除两条消息的协议(protocol)跟踪 -

我发现在这两种情况下设置 DELETED 标志并且不关闭文件夹,然后如果我调用 -

 Message msg[] = inbox.getMessages();

协议(protocol)跟踪的主要区别 -

Gmail 显示

* 1 EXPUNGE
* 1 EXPUNGE
* 0 EXISTS

雅虎显示 -

* 2 EXISTS
* 0 RECENT

尽管我的代码没有更改,也没有调用 folder.close(true);。但是两个邮件服务器对使用相同代码的删除有不同的响应。

一件有趣的事情是,设置 DELETED 标志会从 Yahoo 以及 Gmail 帐户中的给定文件夹中删除邮件。只有 JavaMail 在 Yahoo 的情况下显示它们还活着。

完整详细的协议(protocol)跟踪 -

Gmail 删除协议(protocol)跟踪 -

DEBUG: setDebug: JavaMail version ${mail.version}
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc.,${mail.version}]
DEBUG IMAPS: mail.imap.fetchsize: 16384
DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
DEBUG IMAPS: mail.imap.appendbuffersize: -1
DEBUG IMAPS: mail.imap.minidletime: 10
DEBUG IMAPS: trying to connect to host "imap.gmail.com", port 993, isSSL true
* OK Gimap ready for requests from 59.99.161.5 ky9if13244828pbc.236
A0 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN
A0 OK Thats all she wrote! ky9if13244828pbc.236
DEBUG IMAPS: AUTH: XOAUTH
DEBUG IMAPS: AUTH: XOAUTH2
DEBUG IMAPS: AUTH: PLAIN
DEBUG IMAPS: AUTH: PLAIN-CLIENTTOKEN
DEBUG IMAPS: protocolConnect login, host=imap.gmail.com, user=mymail@gmail.com, password=<non-null>
DEBUG IMAPS: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAPS: AUTHENTICATE PLAIN command result: A1 OK mymail@gmail.com mymail authenticated (Success)
A2 CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH
A2 OK Success
imaps://mymail%40gmail.com@imap.gmail.com
DEBUG IMAPS: connection available -- size: 1
A3 SELECT Inbox
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen XAOL-RECEIVED XAOL-BILLPAY-MAIL XAOL-READ $hasEmbedded $NotJunk $hasAttached NotJunk XAOL-GOOD XAOL-CERTIFIED-MAIL $Junk XAOL-GOODCHECK-DONE)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen XAOL-RECEIVED XAOL-BILLPAY-MAIL XAOL-READ $hasEmbedded $NotJunk $hasAttached NotJunk XAOL-GOOD XAOL-CERTIFIED-MAIL $Junk XAOL-GOODCHECK-DONE \*)] Flags permitted.
* OK [UIDVALIDITY 622695996] UIDs valid.
* 2 EXISTS
* 0 RECENT
* OK [UIDNEXT 136] Predicted next UID.
* OK [HIGHESTMODSEQ 48713]
A3 OK [READ-WRITE] Inbox selected. (Success)
DEBUG IMAPS: IMAPProtocol noop
A4 NOOP
A4 OK Success
A5 STORE 1:2 +FLAGS (\Deleted)
* 1 FETCH (FLAGS (\Deleted))
* 2 FETCH (FLAGS (\Deleted))
A5 OK Success
A6 SEARCH DELETED ALL
* SEARCH
A6 OK SEARCH completed (Success)
DELETED MAILS: 0
DEBUG IMAPS: IMAPProtocol noop
A7 NOOP
* 1 EXPUNGE
* 1 EXPUNGE
* 0 EXISTS
A7 OK Success
TOTAL MAILS: 2
A8 SEARCH DELETED ALL
* SEARCH
A8 OK SEARCH completed (Success)
DELETED MAILS: 0
FOLDER: Inbox

雅虎删除消息协议(protocol)跟踪

DEBUG: setDebug: JavaMail version ${mail.version}
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc.,${mail.version}]
DEBUG IMAPS: mail.imap.fetchsize: 16384
DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
DEBUG IMAPS: mail.imap.appendbuffersize: -1
DEBUG IMAPS: mail.imap.minidletime: 10
DEBUG IMAPS: trying to connect to host "imap.mail.yahoo.com", port 993, isSSL true
* OK [CAPABILITY IMAP4rev1 ID NAMESPACE X-ID-ACLID UIDPLUS LITERAL+ CHILDREN XAPPLEPUSHSERVICE XYMHIGHESTMODSEQ AUTH=PLAIN AUTH=LOGIN AUTH=XYMCOOKIE AUTH=XYMECOOKIE AUTH=XYMCOOKIEB64 AUTH=XYMPKI] IMAP4rev1 imapgate-0.7.68_14.446672 imap424.mail.bf1.yahoo.com
DEBUG IMAPS: AUTH: PLAIN
DEBUG IMAPS: AUTH: LOGIN
DEBUG IMAPS: AUTH: XYMCOOKIE
DEBUG IMAPS: AUTH: XYMECOOKIE
DEBUG IMAPS: AUTH: XYMCOOKIEB64
DEBUG IMAPS: AUTH: XYMPKI
DEBUG IMAPS: protocolConnect login, host=imap.mail.yahoo.com, user=mymail@yahoo.com, password=<non-null>
DEBUG IMAPS: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAPS: AUTHENTICATE PLAIN command result: A0 OK AUTHENTICATE completed - Mailbox size in bytes is 70034
A1 CAPABILITY
* CAPABILITY IMAP4rev1 ID NAMESPACE X-ID-ACLID UIDPLUS LITERAL+ XAPPLEPUSHSERVICE XYMHIGHESTMODSEQ
A1 OK CAPABILITY completed
imaps://mymail%40yahoo.com@imap.mail.yahoo.com
DEBUG IMAPS: connection available -- size: 1
A2 SELECT nsharma
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1379585757] UIDs valid
* OK [UIDNEXT 17] Predicted next UID
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)] Permanent flags
* OK [HIGHESTMODSEQ 5926770610774517536]
A2 OK [READ-WRITE] SELECT completed; now in selected state
DEBUG IMAPS: IMAPProtocol noop
A3 NOOP
A3 OK NOOP completed
DEBUG IMAPS: IMAPProtocol noop
A4 NOOP
A4 OK NOOP completed
A5 STORE 1:2 +FLAGS (\Deleted)
* 1 FETCH (FLAGS (\Deleted))
* 2 FETCH (FLAGS (\Deleted))
A5 OK STORE completed
A6 SEARCH DELETED ALL
* SEARCH 1 2
A6 OK SEARCH completed
DELETED MAILS: 2
DEBUG IMAPS: IMAPProtocol noop
A7 NOOP
* 2 EXISTS
* 0 RECENT
A7 OK NOOP completed
TOTAL MAILS: 2
A8 SEARCH DELETED ALL
* SEARCH 1 2
A8 OK SEARCH completed
DELETED MAILS: 2
FOLDER: nsharma
...details of both mails was printed...

是否有其他方法可以在不调用 folder.close(true); 的情况下删除消息?

谢谢

尼拉姆·夏尔马

最佳答案

是的,请调用 EXPUNGE 或 UID EXPUNGE 。将邮件标记为已删除只是一个标记。要真正摆脱它们,您必须删除它们。

关于java - 无法从 Yahoo IMAP 帐户删除邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18981034/

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