IMAPMessage.getRecipients()和IMAPMessage.getAllRecipients()返回null

时间:2010-06-21 20:24:38

标签: imap javamail

我正在编写IMAP消息轮询器(要在业务应用程序中使用)。我能够连接,遍历Inbox中的消息,读取它们的标题和内容,但调用getAllRecipients()和getRecipients(Message.RecipientType.TO)始终返回null。

Message messages[] = inbox.getMessages();
  for (Message message : messages) {
    IMAPMessage imapMessage = (IMAPMessage) message;
      Address[] toRecipients = imapMessage.getRecipients(Message.RecipientType.TO);
      Address[] allRecipients = imapMessage.getAllRecipients();

这令人费解。收件箱中的邮件已与普通邮件客户端一起发送,因此没有任何异常。

IMAP服务器正在运行Dovecot。

* OK Dovecot ready.
A0 CAPABILITY
* CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS STARTTLS AUTH=PLAIN
A0 OK Capability completed.

这是在执行上述操作时使用Wireshark捕获的相关流量转储(并且还调用了imapMessage.getContent())。

A3 SELECT Inbox
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1277135188] UIDs valid
* OK [UIDNEXT 3] Predicted next UID
A3 OK [READ-WRITE] Select completed.

A4 FETCH 1 (BODYSTRUCTURE)
* 1 FETCH (BODYSTRUCTURE ("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 12 1 NIL NIL NIL))
A4 OK Fetch completed.

A5 FETCH 1 (BODY[TEXT]<0.12>)
* 1 FETCH (BODY[TEXT]<0> {12}
here it is
)
A5 OK Fetch completed.

A6 FETCH 1 (FLAGS)
* 1 FETCH (FLAGS (\Seen))
A6 OK Fetch completed.

A7 FETCH 1 (BODY.PEEK[HEADER])
* 1 FETCH (BODY[HEADER] {399}
Return-Path: <EDITED>
Received: from EDITED; Sat, 5 Jun 2010 15:33:13 -0400
Date: Sat, 5 Jun 2010 15:32:40 -0400
From: EDITED
Message-Id: <EDITED>
Subject: Test Message
Lines: 1
)
A7 OK Fetch completed.

A8 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 1 FETCH (INTERNALDATE "05-Jun-2010 15:33:32 -0400" RFC822.SIZE 411 ENVELOPE ("Sat, 5 Jun 2010 15:32:40 -0400" "Test Message" ((NIL NIL "myediteduser" "myediteddomain")) ((NIL NIL "myediteduser" "myediteddomain")) ((NIL NIL "myediteduser" "myediteddomain")) NIL NIL NIL NIL "<EDITED>"))
A8 OK Fetch completed.

A9 FETCH 2 (BODYSTRUCTURE)
* 2 FETCH (BODYSTRUCTURE (("text" "plain" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 8 0 NIL NIL NIL)("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 341 9 NIL NIL NIL) "alternative" ("boundary" "----=_NextPart_000_0003_01CB1137.CCF78C80") NIL NIL))
A9 OK Fetch completed.

任何提示都表示赞赏。我不知道是否还有其他我应该打电话或者IMAP服务器中是否有设置。我已经查看了IMAPMessage的所有方法,以防在调用getRecipients()和getAllRecipients()之前有什么东西要运行,但什么都没有。谷歌搜索了一段时间,发现我应该没有其他任何东西。

1 个答案:

答案 0 :(得分:0)

关闭它:这是邮件服务器设置的一个问题,现在已经修复了。