Java: Reading Email using Javamail API Example


                  The previous tutorial explains to send email using Javamail API. Now lets see how to read/retreive email in your inbox using Javamail API. Its very simple, this tutorial explains this step by step. If you have not configured Javamail API in your IDE, please download it from here and get it configured only then you will be able to run this program.
                As explained in the previous tutorial let me explain the classes and method used here, that will make us to understand the program in a better way. Below are the steps to read email :

Step 1 - Define Protocol
Step 2 - Get a session instance to read email
Step 3 - Access emails through store class
Step 4 - Read Inbox

Step 1 : Define Protocol
props.setProperty("mail.store.protocol", "imaps")
              First we need to define the protocol for processing emails.
SMTP - is the protocol to send email
POP3 -  is the protocol to receive emails
IMAP- IMAP is an acronym for Internet Message Access Protocol. Its an advanced protocol for receiving messages.
              This property takes two parameters (key, Value) key is "mail.store.protocol" and its value is "imaps" since we are going to read email protocol is defined as "imaps"

Step 2 : Get a session instance to read email
                  This property is used to get a session instance for reading email and its done as shown below in the code.
Session session = Session.getInstance(props, null);

Step 3 : Access emails through store class
Store - An abstract class that models a message store and its access protocol, for storing and retrieving messages. Store provides many common methods for naming stores, connecting to stores, and listening to connection events.
We will be making use of connect(String host,String user,String password) method to connect to specified host and get access to Inbox.
Store store = session.getStore();
store.connect("imap.gmail.com", "yourEmailId@gmail.com", "password");
Folder inbox = store.getFolder("INBOX");

Then we need to open the required folder in Read mode.
 inbox.open(Folder.READ_ONLY);

Summary: So far we have created a session and connected to gmail host with our username and password and got read access to Inbox.

Step 4 : Read Inbox
              We are almost done, now get access to your email using 'Message' class as shown below and typecast the content of the mail to Multipart to read the body of the email.
 Message msg = inbox.getMessage(1);

Here 1 indicates the first email received in your inbox and getMessageCount() will give you the number of emails in your inbox. So read the latest email use,
 Message msg = inbox.getMessage(inbox.getMessageCount());

Output Screenshot

Netbeans Output
Actual Email

Actual Email

ReadingEmail.java         Download here


import java.util.*;
import javax.mail.*;

public class ReadingEmail {
    public static void main(String[] args) {
        Properties props = new Properties();
        props.setProperty("mail.store.protocol", "imaps");
        try {
            Session session = Session.getInstance(props, null);
            Store store = session.getStore();
            store.connect("imap.gmail.com", "yourEmailId@gmail.com", "password");
            Folder inbox = store.getFolder("INBOX");
            inbox.open(Folder.READ_ONLY);
            Message msg = inbox.getMessage(inbox.getMessageCount());
            Address[] in = msg.getFrom();
            for (Address address : in) {
                System.out.println("FROM:" + address.toString());
            }
            Multipart mp = (Multipart) msg.getContent();
            BodyPart bp = mp.getBodyPart(0);
            System.out.println("SENT DATE:" + msg.getSentDate());
            System.out.println("SUBJECT:" + msg.getSubject());
            System.out.println("CONTENT:" + bp.getContent());
        } catch (Exception mex) {
            mex.printStackTrace();
        }
    }
}

            Finally we have successfully read email in java using javamail API...

           Do you like to add your own tutorials here? Here is an opportunity... Check this link ! !             




Reactions:

48 comments :

  1. Very informative, Thanks for sharing, But I came across another java email component by the name of Aspose.Email for Java. It enables Java applications to read and write MS Outlook MSG files from within a Java application and also support Exchange server as well. I am sure it will be helpful.

    ReplyDelete
  2. hey im havving an error 07-26 14:19:10.125: W/System.err(12890): android.os.NetworkOnMainThreadException
    i have permission in manifest

    ReplyDelete
    Replies
    1. This is a java program, I am not sure, are you running this code in Android? Because the exception indicates that.

      Delete
    2. This happens when you try to run a code in the onCreat methode which needs network access. Put in an AsyncTask and it will run fine. :)

      Admin: basically i run your code in my email app on android 4.0.3.

      Delete
    3. have you file of that Android mail app??

      Delete
  3. Respected Sir,
    I am having Error in this program with windows 7 64 Bit Error is Below
    javax.mail.MessagingException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target;
    nested exception is:
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:670)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at inboxreader.InboxReader.main(InboxReader.java:27)
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1886)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
    at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:548)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:352)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)
    at com.sun.mail.iap.Protocol.(Protocol.java:113)
    at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:111)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:637)
    ... 3 more
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
    at sun.security.validator.Validator.validate(Validator.java:260)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
    ... 16 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)

    ReplyDelete
    Replies
    1. common causes of this problem are;
      1. Your server is probably using a test certificate or self-signed certificate instead of a certificate signed by a commercial Certificate Authority. You'll need to install the server's certificate into your trust store.
      2. Firewall or anti-virus program that is preventing your request
      3. There might be some problem with JDK installation which might prevent from finding the certificates for the trusted certificate authorities.
      4. You server might have overridden the JDKs list of trusted certificate authorities.

      Delete
    2. "Install the server's certificate into your trust store."
      How do i do that?

      Delete
    3. just disable your antivirus and try

      Delete
    4. In google account settings, enable "access to less secure apps"

      It is workng perfectly for me, able to get all addresses till now. am facng some issues n MultiPart area....

      Delete
  4. Hey,Sir..Thank you very much for Reply.

    I am Facing some problems with retrieve mail with Imap is i can't fetch mails from own websites mail account,i read on internet that imap running on other port number etc..then how can we specify port number.



    thank you

    My Code as Below...
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package javaapplication1;

    /**
    *
    * @author chetan
    */
    import java.io.IOException;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.search.*;
    public class InboxReader {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {

    Properties pros=System.getProperties();
    try
    {
    Session session=Session.getDefaultInstance(pros,null);

    Store store=session.getStore("imaps");
    store.connect("mail.padmaglobal.com","mail@padmaglobal.com","password");
    //Program is running well with Gmail,Yahoo,etc Mail Service providers email account but did nt run with my own mail server
    // other mail server of other websites

    Folder inbox=store.getFolder("INBOX");
    Folder f[]=store.getDefaultFolder().list();
    for(Folder fd:f)
    {
    System.out.println("\n"+fd.getName());
    }
    System.out.println("Total Messages: " + inbox.getMessageCount());
    System.out.println("New Messages: " + inbox.getNewMessageCount());
    System.out.println("Unread Messages: " + inbox.getUnreadMessageCount());





    inbox.open(Folder.READ_ONLY);
    FlagTerm ft=new FlagTerm(new Flags(Flags.Flag.SEEN),false);
    Message message[]=inbox.search(ft);
    for(int i=0;i<=message.length-1;i++)
    {
    System.out.println((i+1)+":"+message[i].getSubject()+"\n");

    }

    }
    catch (NoSuchProviderException e) {
    e.printStackTrace();
    System.exit(1);
    }
    catch (MessagingException e) {
    e.printStackTrace();
    System.exit(2);
    }
    }
    }

    ReplyDelete
    Replies
    1. Try using mail.imap.port property to manually specify the IMAP server port. This property takes int value.

      Delete
  5. hello sir.. how to configure JavaMail API ?

    ReplyDelete
    Replies
    1. Right click on Project - Properties - Select Libraries on the left- Select Add JAR/Folder button in the pop-up and add your JAR file.
      These steps are mentioned for Netbeans. Pls write to us (cte.opinion@gmail.com) if you need further information

      Delete
    2. Eclipse set up:
      Right click on the project>New >folder> give any name>Finish....
      Copy paste mail.jar to this folder> Right click on the project again,>Build path, configure build path>add jars> Select the jar u just copied>OK>OK

      Delete
  6. I get an exception NoSuchProviderException :no provider for imap

    ReplyDelete
    Replies
    1. Looks like there are some conflicts,
      check whether you have both mail.jar and imap.jar in your classpath. If so, remove imap.jar

      if it is not working, check for other versions of mail.jar or other jars containing javax.mail classes.

      Delete
  7. Hi, i have NPE: when try to get Content from Message! Any suggestions?
    java.lang.NullPointerException
    at javax.mail.internet.MimeUtility.quote(MimeUtility.java:975)
    at javax.mail.internet.ParameterList.quote(ParameterList.java:672)
    at javax.mail.internet.ParameterList.access$200(ParameterList.java:76)
    at javax.mail.internet.ParameterList$ToStringBuffer.addNV(ParameterList.java:640)
    at javax.mail.internet.ParameterList.toString(ParameterList.java:621)
    at javax.mail.internet.ContentType.toString(ContentType.java:221)
    at com.sun.mail.imap.IMAPMessage.getDataHandler(IMAPMessage.java:644)
    at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1420)
    at ReadingEmail.main(ReadingEmail.java:29

    ReplyDelete
    Replies
    1. Make sure that you are using latest version of java mail api

      Delete
  8. hi sir,
    how to read gmail inbox message using java

    ReplyDelete
    Replies
    1. Mohamed, The above tutorial explains how to read inbox in Gmail using java.

      Delete
  9. Hey,Sir..
    I want to set Flag to message which is now UNSEEN or Unread but now i want to set flag that message is seen ,i am using follows code to do this but i dont found right solutions,

    message[row].setFlag(Flags.Flag.SEEN, true);
    inbox.close(true);
    store.close();
    msg.saveChanges();

    ReplyDelete
    Replies
    1. Use folder.expunge() method

      Delete
  10. Hey,Sir,
    I want to bind JProgressBar to process task of fetching Mails from INBOX Using java mail API,

    Thank you!

    ReplyDelete
  11. Hi sir i am getting ( * BYE system error ) when i try to access email through the store class.
    Please advice me.

    Thanks in advance

    ReplyDelete
  12. working fine.. thank you.
    but the content part is displayed as..javax.mail.internet.MimeMultipart@1f49401

    ReplyDelete
  13. Use imap in place of imaps in call to setproperty function....it will work fine then..:)

    ReplyDelete
  14. hi,

    I am facing error while using this code.

    javax.mail.NoSuchProviderException: No provider for imaps
    at javax.mail.Session.getProvider(Session.java:436)
    at javax.mail.Session.getStore(Session.java:511)
    at javax.mail.Session.getStore(Session.java:491)
    at javax.mail.Session.getStore(Session.java:477)
    at ReadingEmail.main(ReadingEmail.java:12)

    here is the code:

    import java.util.*;
    import javax.mail.*;

    public class ReadingEmail {

    public static void main(String[] args) {
    Properties props = new Properties();
    props.setProperty("mail.store.protocol", "imaps");
    try {
    Session session = Session.getInstance(props, null);
    Store store = session.getStore();
    store.connect("imap.gmail.com", "myemailid@gmail.com", "mypassword");
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message msg = inbox.getMessage(inbox.getMessageCount());
    Address[] in = msg.getFrom();
    for (Address address : in) {
    System.out.println("FROM:" + address.toString());
    }
    Multipart mp = (Multipart) msg.getContent();
    BodyPart bp = mp.getBodyPart(0);
    System.out.println("SENT DATE:" + msg.getSentDate());
    System.out.println("SUBJECT:" + msg.getSubject());
    System.out.println("CONTENT:" + bp.getContent());
    } catch (Exception mex) {
    mex.printStackTrace();
    }
    }
    }

    ReplyDelete
  15. thanks , this is really helpfull to me

    ReplyDelete
  16. javax.mail.AuthenticationFailedException is the error i am getting

    ReplyDelete
  17. Thanks for your code. I have added few lines for downloading attachement
    Anybody can refer to this if he/she looking for downloading attachement


    public class ReadingEmail {
    public static void main(String[] args) {
    Properties props = new Properties();
    props.setProperty("mail.store.protocol", "imaps");
    String username = "username";
    String password = "password";

    try {
    Session session = Session.getInstance(props, null);
    Store store = session.getStore();
    store.connect("imap.gmail.com", username, password);
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    int countOfEmails =inbox.getMessageCount();
    Message msg = inbox.getMessage(inbox.getMessageCount());
    Address[] in = msg.getFrom();
    for (Address address : in) {
    }
    MimeMultipart mp = (MimeMultipart) msg.getContent();
    MimeBodyPart bp = (MimeBodyPart) mp.getBodyPart(1);
    bp.saveFile(bp.getFileName());
    System.out.println("SENT DATE:" + msg.getSentDate());
    System.out.println("SUBJECT:" + msg.getSubject());
    System.out.println("CONTENT:" + bp.getContent());

    } catch (Exception mex) {
    mex.printStackTrace();
    }
    }
    }

    ReplyDelete
  18. sir i'm getting following error

    javax.mail.MessagingException: Connection timed out: connect;
    nested exception is:
    java.net.ConnectException: Connection timed out: connect

    ReplyDelete
  19. Dear sir ,
    Thank you very much for provide this knowledge
    when i run this program in net beans it give following error


    Server Output :


    FROM:Kandarp
    java.lang.ClassCastException: java.lang.String cannot be cast to javax.mail.Multipart
    at emailretrival.EmailRetrival.main(EmailRetrival.java:27)
    BUILD SUCCESSFUL (total time: 4 seconds)

    ReplyDelete
  20. thanks for your code,but only one mail i am able to read,how can i read multiple mails?

    ReplyDelete
  21. java.lang.ClassCastException: java.lang.String cannot be cast to javax.mail.Multipart
    at ReadingEmail.main(ReadingEmail.java:29)

    occure for some email reteriving pls sir give the solution

    ReplyDelete
  22. sir how it is implemented in adv. java....same code in adv java pls tell sir

    ReplyDelete
  23. many thanks to you sir, first tutorial regarding reading from a pop3 mailbox with javamail that worked for me :)

    ReplyDelete
  24. hi guys, ı want to use this java codes for android. İs it possible? İf it is not, what dou you suggest me ? please help me. Thanks

    ReplyDelete
  25. any body having idea about android?? How can i retrieve inbox and all email components in android program???

    ReplyDelete
  26. i actually get a error 404 in tomcat when i try linking the jsp page to a servlet page

    ReplyDelete
  27. Thank you very much! Works perfectly, so helpful!

    ReplyDelete
  28. i face some errors when trying this code for fetching my gmail inbox into my android email client app... please do help me..

    //code
    import java.util.*;
    import javax.mail.*;

    public class ReadingEmail {
    public static void main(String[] args) {
    Properties props = new Properties();
    props.setProperty("mail.store.protocol", "imaps");
    try {
    Session session = Session.getInstance(props, null);
    Store store = session.getStore();
    store.connect("imap.gmail.com", "yourEmailId@gmail.com", "password");
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_ONLY);
    Message msg = inbox.getMessage(inbox.getMessageCount());
    Address[] in = msg.getFrom();
    for (Address address : in) {
    System.out.println("FROM:" + address.toString());
    }
    Multipart mp = (Multipart) msg.getContent();
    BodyPart bp = mp.getBodyPart(0);
    System.out.println("SENT DATE:" + msg.getSentDate());
    System.out.println("SUBJECT:" + msg.getSubject());
    System.out.println("CONTENT:" + bp.getContent());
    } catch (Exception mex) {
    mex.printStackTrace();
    }
    }
    }

    ReplyDelete
  29. Hi, Iam getting below error..pls help me in resolving this
    javax.mail.MessagingException: Connection timed out: connect;
    nested exception is:
    java.net.ConnectException: Connection timed out: connect

    ReplyDelete
  30. Hello SIR !
    First of all Thanks for this post.
    Could you please help me out with the following error ?
    Thanks in advance...


    javax.mail.MessagingException: Connection timed out: connect;
    nested exception is:
    java.net.ConnectException: Connection timed out: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:670)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at com.abs.ReadingEmail.main(ReadingEmail.java:21)
    Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:412)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:271)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:258)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:376)
    at java.net.Socket.connect(Socket.java:546)
    at java.net.Socket.connect(Socket.java:495)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:321)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237)
    at com.sun.mail.iap.Protocol.(Protocol.java:116)
    at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:115)
    at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:685)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:636)
    ... 3 more

    ReplyDelete
  31. Getting this error ! Please help !



    javax.mail.MessagingException: java.security.NoSuchAlgorithmException: SSLContext Default implementation not found: ;
    nested exception is:
    java.net.SocketException: java.security.NoSuchAlgorithmException: SSLContext Default implementation not found:
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:726)
    at javax.mail.Service.connect(Service.java:364)
    at javax.mail.Service.connect(Service.java:245)
    at com.abs.ReadingEmail.main(ReadingEmail.java:25)
    Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: SSLContext Default implementation not found:
    at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:4)
    at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:2)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:340)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236)
    at com.sun.mail.iap.Protocol.(Protocol.java:117)
    at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:121)
    at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:746)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:689)
    ... 3 more
    Caused by: java.security.NoSuchAlgorithmException: SSLContext Default implementation not found:
    at java.security.Provider$Service.newInstance(Provider.java:968)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:279)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:217)
    at javax.net.ssl.SSLContext.getInstance(SSLContext.java:27)
    at javax.net.ssl.SSLContext.getDefault(SSLContext.java:28)
    at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:16)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:339)
    ... 8 more
    Caused by: java.lang.Exception: Truststore file does not exist: \path\to\jssecacerts
    at com.ibm.jsse2.ed.a(ed.java:65)
    at com.ibm.jsse2.tc.f(tc.java:19)
    at com.ibm.jsse2.tc.(tc.java:25)
    at java.lang.J9VMInternals.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1549)
    at java.security.Provider$Service.newInstance(Provider.java:954)
    ... 14 more

    ReplyDelete
  32. The server in my outlook is using MAPI protocol. Is it possible with this code with MAPI protocol to access mails from outlook? If not is there some other way out for accessing outlook email from server supporting MAPI protocol ?


    Please help !

    ReplyDelete
  33. HI Admin,

    I tried your given code and I have also integrated current updated jar files. But it is showing runtime exception. Below is my Exception I am getting.Please help me out as soon as possible.

    javax.mail.MessagingException: Connection refused: connect;
    nested exception is:
    java.net.ConnectException: Connection refused: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
    at javax.mail.Service.connect(Service.java:288)
    at javax.mail.Service.connect(Service.java:169)
    at org.genpact.demfor.service.TestPage.main(TestPage.java:20)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
    at com.sun.mail.iap.Protocol.(Protocol.java:107)
    at com.sun.mail.imap.protocol.IMAPProtocol.(IMAPProtocol.java:104)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
    ... 3 more

    ReplyDelete