Hi All,
I used the below code to connect to Mail server of my Organization for accessing my mail box from Unix environment.
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();
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imap");
store.connect("gwes.wide.corp.gwes.com", PORT,"user", "password");
}
I get the below error message even if I use 143 or 993 fot the PORT value in the code:
Exception in thread "main" javax.mail.MessagingException: Connection refused;
nested exception is:
java.net.ConnectException: Connection refused
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at readm.main(readm.java:16)
Caused by: java.net.ConnectException: Connection refused
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:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
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 able to send mails from Unix environment using the IMAP protocol.
Could any one please suggest me a solution for this?
Thanks
I used the below code to connect to Mail server of my Organization for accessing my mail box from Unix environment.
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();
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imap");
store.connect("gwes.wide.corp.gwes.com", PORT,"user", "password");
}
I get the below error message even if I use 143 or 993 fot the PORT value in the code:
Exception in thread "main" javax.mail.MessagingException: Connection refused;
nested exception is:
java.net.ConnectException: Connection refused
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at readm.main(readm.java:16)
Caused by: java.net.ConnectException: Connection refused
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:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
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 able to send mails from Unix environment using the IMAP protocol.
Could any one please suggest me a solution for this?
Thanks