• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

problem connecting to a POP server

 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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 - ksc.th.com, it connects to the POP3 server, but while opening the INBOX folder it gives following exception
javax.mail.MessagingException: Open failed;
nested exception is:
java.io.IOException: Unexpected response:
at com.sun.mail.pop3.POP3Folder.open(POP3Folder.java:170)
at orange.net4nuts.transceiver.services.PopConnector.connect(PopConnector.java:30)
at orange.net4nuts.mbeans.popmbean.PopMailMBean.onMessage(PopMailMBean.java:2079)
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 ksc.th.com 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
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Ankit
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic