Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Mail Exception in Android
    primarykey
    data
    text
    <p>I am facing a strange problem. I am connecting the gmail server through IMAP. It is connecting fine at the <strong>first attempt</strong> fine. But when I connecting the store for the <strong>second time</strong>, I am getting exception. Please help. Below is the code which I have used.</p> <pre><code>String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; try { Properties properties = new Properties(); properties.setProperty("mail.store.protocol", "imaps"); // properties.setProperty("mail.imaps.socketFactory.fallback", "false"); // set this session up to use SSL for IMAP connections properties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); properties.setProperty("mail.imaps.socketFactory.fallback", "false"); // use the simap port for imap/ssl connections. // properties.setProperty("mail.imap.socketFactory.port", "993"); URLName url = new URLName("imap", _INCOMINGMAILSERVER, 993, "", _USERNAME, _PASSWORD); Session session = Session.getInstance(properties,null); session.setDebug(true); //Store store = session.getStore("imaps"); Store store = new IMAPSSLStore(session, url); if (store.isConnected()) { Log.v("Connected", "TRUE"); } else { Log.v("Connected", "FALSE"); /* * store.connect(_OUTGOINGMAILSERVER, _USERNAME, _PASSWORD); if * (store.isConnected()) store.close(); */ Log.v("INCOMING SERVER", _INCOMINGMAILSERVER); //store.connect(_INCOMINGMAILSERVER, _USERNAME, _PASSWORD); store.connect(); } connected = true; </code></pre> <p>THE EXCEPTION</p> <blockquote> <p>================== 05-15 01:31:50.765: W/System.err(19008): javax.mail.MessagingException: SSL handshake aborted: ssl=0x2a8e5238: I/O error during system call, Connection reset by peer; 05-15 01:31:50.765: W/System.err(19008): nested exception is: 05-15 01:31:50.765: W/System.err(19008): javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x2a8e5238: I/O error during system call, Connection reset by peer 05-15 01:31:50.765: W/System.err(19008): at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571) 05-15 01:31:50.765: W/System.err(19008): at javax.mail.Service.connect(Service.java:288) 05-15 01:31:50.765: W/System.err(19008): at javax.mail.Service.connect(Service.java:169) 05-15 01:31:50.765: W/System.err(19008): at javax.mail.Service.connect(Service.java:118) 05-15 01:31:50.765: W/System.err(19008): at com.dts.powermailmanager.Mailmanager._connectToImap(Mailmanager.java:218) 05-15 01:31:50.765: W/System.err(19008): at com.dts.powermailmanager.Mailmanager.connect(Mailmanager.java:365) 05-15 01:31:50.765: W/System.err(19008): at com.dts.classes.PowermailAsync.doInBackground(PowermailAsync.java:157) 05-15 01:31:50.769: W/System.err(19008): at com.dts.classes.PowermailAsync.doInBackground(PowermailAsync.java:1) 05-15 01:31:50.769: W/System.err(19008): at android.os.AsyncTask$2.call(AsyncTask.java:287) 05-15 01:31:50.781: W/System.err(19008): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 05-15 01:31:50.781: W/System.err(19008): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 05-15 01:31:50.781: W/System.err(19008): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 05-15 01:31:50.781: W/System.err(19008): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 05-15 01:31:50.781: W/System.err(19008): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 05-15 01:31:50.781: W/System.err(19008): at java.lang.Thread.run(Thread.java:856) 05-15 01:31:50.781: W/System.err(19008): Caused by: javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x2a8e5238: I/O error during system call, Connection reset by peer 05-15 01:31:50.796: W/System.err(19008): at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method) 05-15 01:31:50.796: W/System.err(19008): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:395) 05-15 01:31:50.796: W/System.err(19008): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.(OpenSSLSocketImpl.java:647) 05-15 01:31:50.796: W/System.err(19008): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:618) 05-15 01:31:50.796: W/System.err(19008): at com.sun.mail.iap.Protocol.initStreams(Protocol.java:132) 05-15 01:31:50.796: W/System.err(19008): at com.sun.mail.iap.Protocol.(Protocol.java:111) 05-15 01:31:50.796: W/System.err(19008): at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:104) 05-15 01:31:50.800: W/System.err(19008): at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538) 05-15 01:31:50.800: W/System.err(19008): ... 14 more</p> </blockquote> <p>OK NOW I AM USING THIS:-</p> <pre><code>Properties properties = new Properties(); properties.setProperty("mail.store.protocol", "imaps"); Session session = Session.getInstance(properties,null); session.setDebug(true); Store store = session.getStore("imaps"); store.connect(_INCOMINGMAILSERVER, _USERNAME, _PASSWORD); </code></pre> <p>Also I close the store after getting message stuffs.</p> <p>But still the same error while connecting for the second time. It seems the server is not responding or the port is somewhat busy while connecting second time. I can't figure it out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload