Results 1 to 3 of 3
- 01-22-2010, 01:57 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 48
- Rep Power
- 0
Facing problem in making connection to mail server
Hi,
Hope you all will be fine. I have a server whose IP is 202.43.124.101 and whose name is ns9.nethyderabad.com. On this server i have an email server named sendmail. Now i want to connect to this server but the problem is HOW?. I have already wrote a program that connect with gmail and it works fine.
I have a local user account on my linux server named masood, since my server name is ns9.nethyderabad.com therefore masood email address become masood@nethyderabad.com. Now i want to connect to this account and want to read emails. The problem is what host name and username and password i use. In case of gmail it's simply pop.gmail.com and your gmail user account and password. But here what i use for host. I also discussed it on linux forum and he replied your servername and mailserver name are same and where you use "gmail.com"(pop.gmail.com)replace it with your mail server name. I tried but it gives me error I tried all possible combinations for host name with pop or without pop. It's a starting portion of my code. Please help.
and the errors areJava Code:public static void main(String[] args) { String host = "ns9.nethyderabad.com"; //also tried pop.ns9.nethyderabad.com and 202.43.124.101 and pop.nethyderabad.com String username = "masood@nethyderabad.com"; String password = "xxx"; //String port = "465"; Scanner scanner = new Scanner(System.in); //Create empty properties Properties props = new Properties(); //props.put("mail.pop3.host", host); //Get Session Session session = Session.getDefaultInstance(props, null); //Get the store try{ Store store = session.getStore("pop3"); System.out.println("Trying to connect host"); store.connect(host, username, password); System.out.println("Connection Successful"); //Get Folder Folder folder = store.getFolder("Inbox"); folder.open(Folder.READ_ONLY);
Line 28 is store.connect(host, username, password);Trying to connect host
javax.mail.MessagingException: Connect failed;
nested exception is:
java.io.IOException: Connect failed
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:176)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at GetMessageExample.main(GetMessageExample.java:28)
Caused by: java.io.IOException: Connect failed
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:11 3)
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java :227)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:172)
... 3 more
BUILD SUCCESSFUL (total time: 22 seconds)
Please help.
Thank youLast edited by Basit56; 01-22-2010 at 02:01 PM.
- 01-22-2010, 06:09 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Hello Basit56,
I cannot help you directly
but here are some hints that could clear up a few thing for you:
Always this line in your code for debug:
...
//Get Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true); // Verbose!
...
Using this, u can see in your console how your client and pop3 server
communicate and exchange messages on this protocol
Every server offers some commands.
Try to connect form Telnet and see what servers offer.
Send some mail to your e-mail and
try to get it using Telnet - it IS very simple:
artran ltd | useful tips
good luck!
- 01-22-2010, 06:27 PM #3
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
This is from JAVAMAIL API - SUN
Q: How do I debug problems connecting to my mail server?
A: The first thing to do when debugging such problems is to determine whether it's a Java problem or a networking problem. Use telnet to try to connect to the remote system. For example, if you're having trouble connecting to the POP3 server named mail.example.com, you would use:
telnet mail.example.com 110
If you get a greeting banner you can simply disconnect. If this works, your networking, name service, firewall, etc. are all set up correctly and your problem is most likely in your Java program.
If it doesn't work, you'll need to check your networking configuration or talk to your network administrator for help. Sometimes a firewall installed on your local machine or on your network will prevent you from connecting to the server. If telnet complains that it doesn't know the host name that you're using, most likely your name service (e.g., DNS) isn't properly configured to resolve internet host names. None of these problems are JavaMail or Java problems.
Usually, when you get a low level SocketException when connecting, the problem is due to your networking configuration. Usually it's not a Java problem.
Similar Threads
-
problem with sending mail usin javaX.mail api
By sandeepsai39 in forum New To JavaReplies: 4Last Post: 11-25-2009, 05:37 AM -
i am facing some problem with <h:selectOneMenu> default One
By sridharavulapati in forum JavaServer Faces (JSF)Replies: 1Last Post: 09-09-2009, 02:08 PM -
Facing problem while sending e-mail
By jay8186 in forum Java ServletReplies: 1Last Post: 03-25-2009, 07:34 AM -
Sql server connection problem
By tanvirtonu in forum JDBCReplies: 1Last Post: 03-31-2008, 12:46 PM -
java mail server
By krismedia in forum New To JavaReplies: 2Last Post: 01-23-2008, 04:41 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks