Problem reading pop3 mailbox

Questions and answers on developing, deploying and using plugins and JavaBeans

Problem reading pop3 mailbox

Postby jdbruijn » Wed Apr 24, 2013 11:00 am

I'm trying to read a pop3 mailbox using SSL, i've got it working on my developer in both a sample solution and in the main solution.
But when I upload the solutions to our production server I get a connection refused error.

This is the code of my test function:
Code: Select all
   var _mail_prop = []
      
   _mail_prop[0] = 'mail.pop3.host='+ _server;
   _mail_prop[1] = 'mail.pop3.ssl.enable=true';
   _mail_prop[2] = 'mail.pop3.port='+ _port;
   _mail_prop[3] = 'mail.pop3.auth=true';
   _mail_prop[4] = 'mail.pop3.user='+_login;
   //Receive mails from pop3 account.

   application.output(_mail_prop);
   try{
      var _msgs = plugins.mail.receiveMail( _login,  _pwd,  true,  0,  null, _mail_prop)
      if (_msgs != null) //if is null error occurred!
      {
         application.output(_msgs.length + " messages in mailbox ", LOGGINGLEVEL.INFO)   
      } else {
         application.output("Error connecting to POP account ", LOGGINGLEVEL.DEBUG)
      }
   }catch(E){
      application.output(E.message)
   }


Error:
javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at com.servoy.extensions.plugins.mail.MailServer.receiveMail(MailServer.java:394)
at com.servoy.extensions.plugins.mail.client.MailProvider.receiveMail(MailProvider.java:297)
at com.servoy.extensions.plugins.mail.client.MailProvider.js_receiveMail(MailProvider.java:278)
at sun.reflect.GeneratedMethodAccessor489.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:367)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3666)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3135)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:537)
at com.servoy.j2db.plugins.ClientPluginAccessProvider$MethodExecutor.run(ClientPluginAccessProvider.java:514)
at com.servoy.j2db.server.headlessclient.SessionClient.invokeAndWait(SessionClient.java:1209)
at com.servoy.j2db.server.headlessclient.SessionClient.invokeLater(SessionClient.java:1199)
at com.servoy.j2db.plugins.ClientPluginAccessProvider$1.run(ClientPluginAccessProvider.java:441)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:107)
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:261)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:206)
... 24 more


The mailbox is available from any ip address according to the customer and our server provider tells me that the server should be able to connect through the ssl-port.

Can anybody see what i'm doing wrong here? I'm lost and i've got an angry customer asking me why this isn't working.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby Harjo » Wed Apr 24, 2013 1:31 pm

what happens if you do:

Code: Select all
telnet pop.googlemail.com 995


on the server?

I assume you are using the same/ or other domainname and port?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Problem reading pop3 mailbox

Postby jdbruijn » Wed Apr 24, 2013 1:55 pm

I'm not sure what response i'm supposed to get. When I enter that into a command prompt, I get a black windows with a blinking cursor and after a while the prompt returns.
This happens for both the googlemail and my customer server.

I've uploaded the test solution to a testserver on my local domain (which is 6.1 not 6.0 as the production server) I get the same error: connection refused
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby Harjo » Wed Apr 24, 2013 1:59 pm

yes that means indeed the port 995 is not blocked, and you have access to that domain and port.

Are you doing this in smart-client or web-client?
if in smart-client, you could try to test it in web-client, because that has a different way of class loading....

what you also could try is testing this with a gmail acount (be sure pop3 is enabled) what happens than?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Problem reading pop3 mailbox

Postby jdbruijn » Wed Apr 24, 2013 2:26 pm

Tried with gmail account, but same results:
it works in my developer
it does not work on the production server, my local test server (tested both web- and smartclient)
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby jdbruijn » Thu May 16, 2013 9:20 am

After a restart of the server the problem seemed to be gone. I was able to read the email box for a couple of weeks.
But now the problem is back again:
My development machine can access the mailbox, but the server gets the same error again:
Code: Select all
javax.mail.MessagingException: Connect failed;
     nested exception is:
       java.net.ConnectException: Connection refused: connect
       at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:210)
       at javax.mail.Service.connect(Service.java:295)
       at javax.mail.Service.connect(Service.java:176)
       at com.servoy.extensions.plugins.mail.MailServer.receiveMail(MailServer.java:394)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
       at sun.rmi.transport.Transport$1.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at sun.rmi.transport.Transport.serviceCall(Unknown Source)
       at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
       at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(Unknown Source)
       at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
       at java.net.PlainSocketImpl.connect(Unknown Source)
       at java.net.SocksSocketImpl.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at java.net.Socket.connect(Unknown Source)
       at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
       at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
       at com.sun.mail.pop3.Protocol.<init>(Protocol.java:107)
       at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:261)
       at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:206)
       ... 17 more

Has anybody got any suggestions for me on how to permanently fix this problem?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby Harjo » Thu May 16, 2013 9:48 am

if nothing has changed, something is going on with your email-server.
are there not any ban-restrictions (too many connections? too many wrong login's ) that has banned the ip-address of your server?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Problem reading pop3 mailbox

Postby jdbruijn » Thu May 16, 2013 10:11 am

I'll ask if this can be an issue.
However I think it is not, because I can replicate the problem on my test server while I don't have an issue on my development machine. Both the test server and development machine access the web through the same IP. So I would expect neither of them to be able to connect
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby jdbruijn » Thu May 16, 2013 10:31 am

i've tried the following website on the server and it shows it can connect to the pop3 box:
https://www.wormly.com/test_pop3_mail_server

So the problem is not in the connection to the pop3 box, but it is in my servoy solution.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby Harjo » Fri May 17, 2013 10:45 am

You could try to use the free mailPro plugin Dr Maison, for a quick test.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Problem reading pop3 mailbox

Postby jdbruijn » Fri May 17, 2013 12:12 pm

when I try to read the mailbox using outlook express I get a Certificate warning. When I have accepted the warning (one time only) OE can read the mailbox.
Can this be a reason why the plugin cannot access the mailbox?
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Problem reading pop3 mailbox

Postby Harjo » Fri May 17, 2013 12:18 pm

ah, yes, that could be indeed a problem! try the mailPro plugin, I believe that one has better support for that.
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Problem reading pop3 mailbox

Postby jdbruijn » Tue May 21, 2013 8:32 pm

The MailPro plugin does seem to accept the connection, so i guess i'll just have to rewrite some parts of my mail handling to use the mailpro plugin.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 19 guests

cron