File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes problem connecting to a POP server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "problem connecting to a POP server" Watch "problem connecting to a POP server" New topic

problem connecting to a POP server

Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
I am using Java Mail API to connect to various POP3 servers. It works for most of the POP3 servers, but in case of one particular POP3 server -, it connects to the POP3 server, but while opening the INBOX folder it gives following exception
javax.mail.MessagingException: Open failed;
nested exception is: Unexpected response:
at orange.net4nuts.mbeans.popmbean.PopMailMBean.onMessage(
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke
I tried opening the folder once in READ_WRITE mode and second time in READ_ONLY mode, both giving the same error.
Now, if I manually do telnet to on port 110, from there I can read the emails without any problems.
Can somebody help me on this??
Ankit Doshi
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
The problem here was that, when you call open() method on the POP3Folder, the API fires the STAT command of the POP3 protocol. Now, in case of this server, the server returns one blank line (which is not the case with most of the other servers) and then gives back the output of the STAT command. And in the Mail API it reads a single line only. The reason for the extra new line is still a confusion.
Anyways, changing the code to read extra line (if available from stream) on receiving a blank line does the trick.
I agree. Here's the link:
subject: problem connecting to a POP server
It's not a secret anymore!