users@glassfish.java.net

IMAP/TLS Problem in connecting using standalone application.

From: <glassfish_at_javadesktop.org>
Date: Thu, 01 Mar 2007 11:55:18 PST

Hi All,

I have a IMAP4 server running with TLS authentication switched on and have self signed certificate. I do not want to

install certificates so I tried DummySSLSocketFactory and DummyTrustManager provided by SUN but it gives following

error. Can anyone help me here?


DEBUG: setDebug: JavaMail version 1.3.3
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
javax.mail.MessagingException: Connection refused: connect;
  nested exception is:
        java.net.ConnectException: Connection refused: connect
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:461)
        at javax.mail.Service.connect(Service.java:236)
        at javax.mail.Service.connect(Service.java:137)
        at getmail.receiveEmails(getmail.java:40)
        at getmail.main(getmail.java:18)



DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
javax.mail.MessagingException: Unconnected sockets not implemented;
nested exception is:
java.net.SocketException: Unconnected sockets not implemented
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at getmail.receiveEmails(getmail.java:27)


Here is my class.

import java.io.IOException;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store;
public class getmail {
        // myauth auth;
        public static void main(String args[]) throws Exception {
                getmail getmail = new getmail();
                getmail.receiveEmails();
        }
        private void receiveEmails() throws NoSuchProviderException, MessagingException, IOException {
                // String host, name, passwd;
                String host = "HOST";
                String name = "USER";
                String passwd = "PASSWORD";
                java.security.Security.setProperty("ssl.SocketFactory.provider", "DummySSLSocketFactory");
                // Get a Properties object
                Properties props = System.getProperties();
                props.setProperty("mail.imaps.socketFactory.fallback", "false");

                Session session = Session.getDefaultInstance(props, null);
                session.setDebug(true);
                Store store = session.getStore("imaps");
                try {
                        store.connect(host, name, passwd); // exception here
                        System.out.println("store connected");
                } catch (Exception e) {
                        // System.out.println("Error :" + e.toString());
                        e.printStackTrace();
                        System.exit(1);
                }
}

Thanks in advance.

-Prasad
[Message sent by forum member 'inditrozen' (inditrozen)]

http://forums.java.net/jive/thread.jspa?messageID=205897