|
|
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.
|
|

04-16-2008, 05:20 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
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);
}
}
}
|
|

04-17-2008, 09:37 AM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
|
|
|
What specificly this program will do?
And when asking help, please be also specific....
regards,
sukatoa
|
|

04-17-2008, 09:43 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
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.
|
|

04-17-2008, 03:49 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
Javamail
This program should recieve mail from mail server and display on the console using javamail, but not doing so. thanks for your interest.
|
|

04-18-2008, 05:05 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
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)
|
|

04-18-2008, 05:28 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
Javamail
I work for a company, It is mail server in my company. Thanks for your interest
|
|

04-18-2008, 06:01 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
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)
|
|

04-18-2008, 07:14 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
javamail
No, I could not solve the problem. I gave username and password properly not able to connect to mail server.
|
|

04-18-2008, 07:26 AM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
|
|
|
Check proper IP Address of your mail server and disable Virus scan software like McAfee.
sanjeev
|
|

04-18-2008, 07:39 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
Originally Posted by sanjeevtarar
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)
|
|

04-18-2008, 07:41 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
javamail
Ok i will do that, is there anything related to proxy server, through we connect.
Thanks anyways
|
|

04-18-2008, 07:42 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
Originally Posted by v_mallikarjun
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)
|
|

04-18-2008, 08:04 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
ok sure i will give a try, thanks
|
|

04-18-2008, 08:11 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
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)
|
|

04-18-2008, 08:32 PM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 7
|
|
|
Javamail
Ok i will.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|