Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Failed to load IMAP envelope

843834Feb 23 2010 — edited Feb 23 2010
I'm using the code below to simply test whether I can access messages in a specific account on Domino Server 8.something. At the moment, there are more than 3000 messages in this account, most of which are unread. The code works as I expect until I hit message 2675, which produces the following exception. I can produce this error by calling the following methods of the javax.mail.internet.MimeMessage class: getSubject(), getMessageID(), getFrom(). I've run this code on Ubuntu 9.0.4 as well as Mac OS X Snow Leopard. I've also compiled and executed this code using Java Mail 1.4.2 and Java Mail 1.4.3. I've posted my .properties file, the protocol debug statements, a code snippet, and a snippet from my log4j file so the point at which the error occurs is clear. I'm suspicious of the two quotation marks after NIL NIL in front of Steve Cooker"SCooker_SVP in the protocol debug statements. Thanks in advance for any input.

mail.store.protocol=imap
mail.transport.protocol=smtp
mail.debug.quote=true
mail.debug=true
mail.imap.port=143


A2678 FETCH 2675 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 2675 FETCH (ENVELOPE ("Thu, 04 Feb 2010 09:24:52 -0500" "Monster To Acquire Yahoo!'s HotJobs" (("Steve Cooker" NIL "SCooker_SVP" "monster.com")) (("Steve Cooker" NIL "SCooker_SVP" "monster.com")) ((NIL NIL ""Steve Cooker"SCooker_SVP" "monster.com")) ((NIL NIL "stephanieh" "bsp-mail.com")) NIL NIL NIL "<emsg.6fbd.38b18.126995e8142@unica7emsg201.be.monster.com>") INTERNALDATE "04-Feb-2010 14:23:57 +0000" RFC822.SIZE 18662)
A2678 OK FETCH completed

2010-02-23 13:30:49,723 [main] DEBUG com.digitiliti.pyramid.email.mailet.test.EmailClient - checkInbox(): message 2675
2010-02-23 13:30:49,806 [main] ERROR com.digitiliti.pyramid.email.mailet.test.EmailClient -
javax.mail.MessagingException: Failed to load IMAP envelope
at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1196)
at com.sun.mail.imap.IMAPMessage.getFrom(IMAPMessage.java:223)
at com.digitiliti.pyramid.email.mailet.test.EmailClient.checkInbox(EmailClient.java:153)
at com.digitiliti.pyramid.email.mailet.test.EmailIngestorMailetTest.testEMailService(EmailIngestorMailetTest.java:57)
at com.digitiliti.pyramid.email.mailet.test.EmailIngestorMailetTest.main(EmailIngestorMailetTest.java:39)


public void checkInbox() throws MessagingException, IOException {
log.debug("checkInbox(): checking inbox...");
try {
Store store = session.getStore();
store.connect();
Folder root = store.getDefaultFolder();
Folder inbox = root.getFolder("inbox");
inbox.open(Folder.READ_WRITE);
Message[] msgs = inbox.getMessages();
if (msgs.length == 0) {
System.out.println("checkInbox(): No messages in mailbox.");
inbox.close(true);
store.close();
} else {
log.debug("checkInbox(): " + msgs.length + " messages in inbox.");
for (int i = 0; i < msgs.length; i++) {
MimeMessage mimeMessage = (MimeMessage) msgs;
log.debug("checkInbox(): message " + (i+1));
log.debug("checkInbox(): subject = " + mimeMessage.getFrom());
log.debug("checkInbox(): message ID = "+mimeMessage.getMessageID());
// try {
// writeToFile(mimeMessage);
// } catch (MessagingException e) {
// log.error(null, e);
// } catch (IOException io) {
// log.error(null, io);
// }
}

inbox.close(true);
store.close();
}
} catch (MessagingException e) {
log.error(null, e);
}
}

Comments

Bill Shannon-Oracle
You're right to be suspicious. It's a bug in the server. The IMAP response is clearly incorrect.
Use the workaround in the JavaMail FAQ to read the message:
[http://java.sun.com/products/javamail/FAQ.html#imapserverbug|http://java.sun.com/products/javamail/FAQ.html#imapserverbug]

I suspect that if you examine the address headers for that message you'll discover that there's
some unusual (or incorrect) quoting in the header that's confusing Domino.

In any event, please report the bug to IBM. Possibly they already have a patch available.
843834
Thank you. I'll report the bug to IBM. Can you point me in the direction of information about correctly formed IMAP responses?
Bill Shannon-Oracle
The complete IMAP protocol syntax is in the IMAP spec - RFC 3501.
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 23 2010
Added on Feb 23 2010
3 comments
4,811 views