gpt4 book ai didi

java - 无法删除域 .co.jp 类型的电子邮件

转载 作者:太空宇宙 更新时间:2023-11-04 09:39:24 27 4
gpt4 key购买 nike

我使用java邮件API编写了java代码。它为 IMAP 帐户执行以下操作:

  1. 将邮件标记为已读/未读。
  2. 发送/删除邮件。

我的代码适用于大多数 IMAP 邮件帐户。我根据邮件的 UID 获取邮件。但令人惊讶的是,它不适用于具有域名 xxx12@yahoo.co.jp 的邮件帐户的删除操作。我还尝试创建一个域中包含 @yahoo.co.jp 的新帐户。

适用于具有 @yahoo.co.jp 的邮件帐户的内容是:

  1. 标记为已读/未读。

到目前为止,我已经尝试过此链接 Delete Email on Server using javax.mail并阅读https://javaee.github.io/javamail/FAQ 。我还尝试过使用其他 yahoo 邮件(即 xxx12@yahoo.com)以及 gmail 邮件帐户进行删除操作,其中以下代码按预期工作,测试的两种类型都是 IMAP 类型。

Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
props.put("mail.smtp.starttls.enable", true);
session = Session.getInstance(props, null);
session.setDebug(true);
store = session.getStore("imaps");
store.connect("host", "port","uname","pass");
inbox = (IMAPFolder) store.getFolder(folderName);
inbox.open(Folder.READ_WRITE);
long uid = Long.parseLong(messageId);
message = inbox.getMessageByUID(uid);
if (message != null) {
if(form.getFlagType().equals("read")){
Flags read = new Flags(Flags.Flag.SEEN);
message.setFlags(read, true);
} else if(form.getFlagType().equals("unread")){
Flags unread = new Flags(Flags.Flag.SEEN);
message.setFlags(unread, false);
} else if(form.getFlagType().equals("delete")){
Flags deleteMail = new Flags(Flags.Flag.DELETED);
message.setFlags(deleteMail, true);
}
}
inbox.close(true);
catch(Exception e){
e.printStackTrace();
}

上面代码中写入的行message.setFlags(deleteMail, true);

给出如下所示的异常(exception):

javax.mail.MessagingException:

A4 NO [CANNOT] STORE It's not possible to perform specified operation;

嵌套异常是:

com.sun.mail.iap.CommandFailedException: A4 NO [CANNOT] STORE It's not possible to perform specified operation

我想删除以 yahoo.co.jp 作为域的邮件。任何帮助将不胜感激。

更新:

添加session.setDebug(true);

我发现了以下内容:

A2 SELECT INBOX
* 3 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1557837307] UIDs valid
* OK [UIDNEXT 20006] Predicted next UID
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $Junk $NotJunk)
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Seen $Forwarded $Junk $NotJunk)] Permanent flags
* OK [HIGHESTMODSEQ 27]
A2 OK [READ-WRITE] SELECT completed; now in selected state
A3 UID FETCH 20005 (UID)
* 3 FETCH (UID 20005)
A3 OK UID FETCH completed
A4 STORE 3 +FLAGS (\Deleted)
A4 NO [CANNOT] STORE It's not possible to perform specified operation
DEBUG IMAPS: IMAPProtocol noop
A5 NOOP
A5 OK NOOP completed
A6 CLOSE
A6 OK CLOSE completed
DEBUG IMAPS: added an Authenticated connection -- size: 1
DEBUG IMAPS: IMAPProtocol noop
A7 NOOP
A7 OK NOOP completed
A8 LOGOUT
* BYE IMAP4rev1 Server logging out
A8 OK LOGOUT completed
DEBUG IMAPS: IMAPStore connection dead
DEBUG IMAPS: IMAPStore cleanup, force false
DEBUG IMAPS: IMAPStore cleanup done

如果您需要有关该问题的更多详细信息,请询问。

最佳答案

我认为服务器出于某种原因限制了您,这就是您无法从邮件服务器删除邮件的原因。您可以联系您的邮件管理员。否则java代码没有任何问题。

关于java - 无法删除域 .co.jp 类型的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56148668/

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