Hi All,
Below is the code I use in an Unix environment to connect to my organization's mail server(This is to read mails in my Inbox).

import javax.mail.*;
import java.sql.*;
import javax.mail.internet.*;
import java.util.*;
 
public class readm
{
public static  void main(String args[]) throws MessagingException
{
//Properties props = new Properties();
 
Properties props =System.getProperties();
 props.put("mail.imap.host", "imap.jcom.net");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imap");
store.connect("gwes.wide.corp.gwes.com", 25, "user", "password");
 
}
 
}

I am getting an exception as below:

Exception in thread "main" javax.mail.MessagingException: 220 gwes.wide.corp.gwes.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Wed, 3 Sep 2008 08:58:10 -0400 ;
  nested exception is:
        com.sun.mail.iap.ConnectionException: 220 gwes.wide.corp.gwes.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Wed, 3 Sep 2008 08:58:10 -0400 
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:569)
        at javax.mail.Service.connect(Service.java:288)
        at readm.main(readm.java:17)
Caused by: com.sun.mail.iap.ConnectionException: 220 gwes.wide.corp.gwes.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at  Wed, 3 Sep 2008 08:58:10 -0400 
        at com.sun.mail.imap.protocol.IMAPProtocol.processGreeting(IMAPProtocol.java:230)
        at com.sun.mail.iap.Protocol.<init>(Protocol.java:114)
        at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
        ... 2 more

I am not ble to understand the exception but the server is not refusing connection. Could any body please help me out to solve this.

hi, you can also find your code for mail through java mail api.. mail via gmail account

Comments
This forum is not for spamming your links.
This article has been dead for over six months. Start a new discussion instead.