Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2008, 05:20 AM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
Javamail
javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:161)
at javax.mail.Service.connect(Service.java:288)
at javax.mail.Service.connect(Service.java:169)
at mail.Test9.main(Test9.java:37)
Caused by: java.net.ConnectException: Connection refused: connect
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.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(Socke tFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFe tcher.java:189)
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94 )
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java :214)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3St ore.java:157)
... 3 more


The above is the exception while executing connect statementfor the code given below, Can anyone help me out please my final year project end date is approaching





package mail;

import java.io.FileInputStream;
import java.util.Iterator;
import java.util.Properties;

import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Store;

public class Test9 {
public static void main(String[] args) {
Properties prop = new Properties();
FileInputStream file = null;

try{
int j = 0 ;
file = new FileInputStream("C:\\new\\MailProperties.txt");
prop.load(file);
Iterator it = prop.keySet().iterator();
String values[] = new String[5];
String keys[] = new String[5];
while(it.hasNext()) {
String key = (String)it.next();
String value = prop.getProperty(key);
keys[j] = key;
values[j] = value;
j++;
}
String host = values[1];
String username = values[2];
String password = values[0];
prop.put("mail.pop3.host", host);
Session session = Session.getDefaultInstance(prop, null);
Store store = session.getStore("pop3");
store.connect(host,username, password);
Folder folder = store.getFolder("Inbox.dbx");
folder.open(Folder.READ_ONLY);
Message message[] = folder.getMessages();
//Display from (only first) and subject of messages
for (int i=0, n=message.length; i<n; i++) {
System.out.println(i + ": "
+ message[i].getFrom()[0]
+ "\t" + message[i].getSubject());
System.out.println(message[i].getContent());
}
folder.close(false);
store.close();
} catch(Exception e) {
System.out.println(e);
}
}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-17-2008, 09:37 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
What specificly this program will do?

And when asking help, please be also specific....

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 09:43 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Provide more details about your question. And also please read our FAQ page before posting next time.

At the time if you don't have enough time to read it, please put your code withing code tags.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)

Last edited by Eranga : 04-17-2008 at 09:53 AM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 03:49 PM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
Javamail
This program should recieve mail from mail server and display on the console using javamail, but not doing so. thanks for your interest.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 05:05 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, what is your mail server. Your own coding one or an open source. There are lots of open sources servers. May be an Apache have a solution for you.

First think about the mail server you going to use.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-18-2008, 05:28 AM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
Javamail
I work for a company, It is mail server in my company. Thanks for your interest
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-18-2008, 06:01 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, did you solve the problem? Seems to me, depend on your error code put in the first post, there is a connection error may be.

I can see a connection refused exception on the second line of the error code.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 04-18-2008, 07:14 AM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
javamail
No, I could not solve the problem. I gave username and password properly not able to connect to mail server.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 04-18-2008, 07:26 AM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road

Check proper IP Address of your mail server and disable Virus scan software like McAfee.

sanjeev
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-18-2008, 07:39 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by sanjeevtarar View Post

Check proper IP Address of your mail server and disable Virus scan software like McAfee.

sanjeev
Yep, firewall too.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-18-2008, 07:41 AM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
javamail
Ok i will do that, is there anything related to proxy server, through we connect.

Thanks anyways
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 04-18-2008, 07:42 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Quote:
Originally Posted by v_mallikarjun View Post
No, I could not solve the problem. I gave username and password properly not able to connect to mail server.
That's what I try to pointed pal. As I said, your exceptions list give an idea to me that it's all about your network connection. Something wrong with it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 04-18-2008, 08:04 AM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
ok sure i will give a try, thanks
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 04-18-2008, 08:11 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, try it an see.

At the same time mallikarjun, next time if you want to delete a replay please contact one of our moderator. They can do it safely for you
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 04-18-2008, 08:32 PM
Member
 
Join Date: Apr 2008
Posts: 7
v_mallikarjun is on a distinguished road
Javamail
Ok i will.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using JavaMail API consult4u Networking 0 08-09-2007 11:15 AM
Sending mail Using JAVAMAIL peiceonly Advanced Java 3 07-19-2007 03:11 PM
This is Regarding JSP with javamail venkatkomalli Advanced Java 3 07-19-2007 03:07 PM
530 5.7.0 Authentication Required - JavaMail gmail simon Advanced Java 1 07-15-2007 12:52 AM
JavaMail:Authentication required error bbq Advanced Java 1 07-05-2007 05:16 AM


All times are GMT +3. The time now is 12:42 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org