PlanetJava
Custom Search

java-sun-javamail-general
[Top] [All Lists]

javax.mail.MessagingException: Failed to load IMAP envelope

Subject: javax.mail.MessagingException: Failed to load IMAP envelope
Date: Tue, 21 Oct 2008 07:14:57 -0600
Hi,
I've got a funny problem which causes the following exception. It's funny
because the program is running on my own machine, but it is not running on
the machine of a colleague of mine (actually, it is running without problems
on at least two different machines in different networks; the exactly same
problems occur also on at least two different machines). We are running the
exact same program code, the exact same parameters etc. pp.
javax.mail.MessagingException: Failed to load IMAP envelope
        at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1226)
        at com.sun.mail.imap.IMAPMessage.getSubject(IMAPMessage.java:331)
        at
de.soknos.components.dispatcher.impl.DispatcherImpl.processNewMail(DispatcherImpl.java:218)
        at
de.soknos.components.dispatcher.impl.DispatcherImpl.pullMessagesFromDispatcher(DispatcherImpl.java:484)
        at
de.soknos.components.dispatcher.impl.DispatcherImpl.main(DispatcherImpl.java:62)
Actually, this happens when the first message from "INBOX" is fetched, the
corresponding DEBUG-output on the console is:
A4 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 1 FETCH (ENVELOPE ("Thu, 16 Oct 2008 19:19:19 +0200" "[PROCESSED] Fwd:
Test Nummero 3 [MESSAGE]" (("Stefan Schulte" NIL "ste.schulte"
"gmail.com")) (("Stefan Schulte" NIL "ste.schulte" "gmail.com")) (("Stefan
Schulte" NIL "ste.schulte" "gmail.com")) ((NIL NIL "soknos"
"kom.tu-darmstadt.de")) NIL NIL
"<[email protected]>"
"<[email protected]>") INTERNALDATE
"16-Oct-2008 19:19:19 +0200" RFC822.SIZE 4696)
A4 OK FETCH completed.
This output is exactly the same for my colleague and me. Nevertheless, the
MessagingException occurs only on his machine.
However there seems to be more than this - while it was sufficient to
connect to the INBOX by                         
Store store = session.getStore("imap"); store.connect();
we had to change this to 
Store store = session.getStore("imap");         
store.connect(session.getProperty("mail.imap.host"),
session.getProperty("mail.imap.user"),                  
session.getProperty("mail.user.password"));
Before this, my colleague was getting an AuthenticationFailedException.
Furthermore, while I am able to send messages without any problems, the
mails sent by my colleague feature the wrong subject and "From". On the
other hand, setText() and setRecipients() work absolutely fine. Here comes
the corresponding code:
private void sendMail(Session session,
            String subject, String url, String content,
            String recipi, boolean attachment) throws MessagingException,
            AddressException {
        final Properties props = session.getProperties();
        SMTPMessage msg = new SMTPMessage(session);
        Address[] address = new Address[1];
        address[0] = new
InternetAddress(props.getProperty("mail.smtp.from"));
        msg.addFrom(address);
       msg.setRecipients(javax.mail.Message.RecipientType.TO,
                recipi);
        msg.setSubject(subject);
        msg.setReplyTo(msg.getFrom());
        inhalt = inhalt+"\n"+url;
        msg.setText(inhalt, "UTF-8");
        msg.setSentDate(new Date());
        Transport tr = session.getTransport("smtp");
tr.connect(props.getProperty("mail.smtp.host"),props.getProperty("mail.smtp.user"),
                props.getProperty("mail.smtp.password"));
        msg.saveChanges();
        tr.sendMessage(msg, msg.getAllRecipients());
        tr.close();
        try {
            saveSentMail(msg);
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
Has anybody ever heard of this? Any help is really appreciated!
===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVAMAIL-INTEREST".  For general help, send email to
[email protected] and include in the body of the message "help".
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy