I'm writing an IMAP message poller (to be used from within a business app). I'm able to connect, iterate through the messages in Inbox, read their headers and content but calls to getAllRecipients() and getRecipients(Message.RecipientType.TO) always return null.
Message messages[] = inbox.getMessages();
for (Message message : messages) {
IMAPMessage imapMessage = (IMAPMessage) message;
Address[] toRecipients = imapMessage.getRecipients(Message.RecipientType.TO);
Address[] allRecipients = imapMessage.getAllRecipients();
This is puzzling. The messages in the Inbox have been sent with regular mail clients so there is nothing unusual with them.
The IMAP server is running 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.
This is the relevant traffic dump captured with Wireshark while doing the above (and also calling 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.
Any hints are appreciated. I don't know if there is anything else I should be calling or if there is a setting in the IMAP server. I've looked at all methods of the IMAPMessage in case there was something to run before calling getRecipients() and getAllRecipients() but there was nothing. Also googled for a while and found nothing else I should have called.