problem in reading mail from pop3 server
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ij_kl
Posted On:   Friday, April 17, 2009 04:06 PM

Hi to all, I am new to java mail. i want to recieve an email using pop3,while compiling i am getting the following errors: Exception in thread "main" javax.mail.AuthenticationFailedException: internal server error at com.sun.mail.pop3.POP3Store.protocolConnect (POP3Store.java:159) at javax.mail.Service.connect(Service.java:288) at javax.mail.Service.connect(Service.java:169) at ReplyExample.main(ReplyExample.java:23) The followings are the source code I got from http://java.sun.com/developer/onlineTraining/JavaMail/exercises/MailReply/. but couldn't run it successfully import java.io.*; import java.util.Pr   More>>

Hi to all,

I am new to java mail. i want to recieve an email using pop3,while compiling i am getting the following errors:




Exception in thread "main" javax.mail.AuthenticationFailedException: internal server error

at com.sun.mail.pop3.POP3Store.protocolConnect (POP3Store.java:159)

at javax.mail.Service.connect(Service.java:288)


at javax.mail.Service.connect(Service.java:169)

at ReplyExample.main(ReplyExample.java:23)



The followings are the source code I got from http://java.sun.com/developer/onlineTraining/JavaMail/exercises/MailReply/. but couldn't run it successfully
			

import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class ReplyExample {
public static void main (String args[]) throws Exception {
String host = "pop.free.fr";
String sendHost = " smtp.free.fr";
String username = "toto";
String password ="********";
String from = "toto@live.fr";

// Create empty properties
Properties props = System.getProperties();
props.put("mail.smtp.host", sendHost);

// Get session
Session session = Session.getDefaultInstance(props, null);

// Get the store
Store store = session.getStore("pop3");
store.connect(host, username, password);

// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);

BufferedReader reader = new BufferedReader (
new InputStreamReader(System.in));

// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i
System.out.println(i + ": " + message[i].getFrom()[0]
+ " " + message[i].getSubject());

System.out.println("Do you want to reply to the message? [YES to reply/QUIT to end]");
String line = reader.readLine();
if ("YES".equals(line)) {

// Create a reply message
MimeMessage reply = (MimeMessage)message[i].reply(false);

// Set the from field
reply.setFrom(new InternetAddress(from));

// Create the reply content, copying over the original if text
MimeMessage orig = (MimeMessage)message[i];
StringBuffer buffer = new StringBuffer("Thanks

");
if (orig.isMimeType("text/plain")) {
String content = (String)orig.getContent();
StringReader contentReader = new StringReader(content);
BufferedReader br = new BufferedReader(contentReader);
String contentLine;
while ((contentLine = br.readLine()) != null) {
buffer.append("> ");
buffer.append(contentLine);
buffer.append("
");
}
}

// Set the content
reply.setText(buffer.toString());

// Send the message
Transport.send(reply);

} else if ("QUIT".equals(line)) {
break;
}
}

// Close connection
folder.close(false);
store.close();
}
}




Can any one help me out in clearing this problem ?
Thanks in advance.
   <<Less
About | Sitemap | Contact