dcsimg
I am getting this error with my yahooID when i run the follwoing class!_NEWLINE_!javax.mail.AuthenticationFailedException
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, January 21, 2002 07:18 PM

I am getting this error with yahooID. javax.mail.AuthenticationFailedException at javax.mail.Service.connect(Service.java:265) at javax.mail.Service.connect(Service.java:135) at MailExample.main(MailExample.java:48) My code is like this public class MailExample{ public static void main (String args[]) throws Exception { String host = smtp.mail.yahoo.com; String from = naren97008@yahoo.com; String to = dvn_reddy@hotmail.com; String username = "naren97008"; String password = "narendra"; try{ // Get system properties // Setup mail server Properties props = new Properties(); props.put("   More>>

I am getting this error with yahooID.
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:265)
at javax.mail.Service.connect(Service.java:135)
at MailExample.main(MailExample.java:48)



My code is like this
public class MailExample{
public static void main (String args[]) throws Exception {
String host = smtp.mail.yahoo.com;
String from = naren97008@yahoo.com;
String to = dvn_reddy@hotmail.com;

String username = "naren97008";
String password = "narendra";

try{
// Get system properties
// Setup mail server
Properties props = new Properties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth","true");

// Get session
PopupAuthenticator popAuthenticator = new PopupAuthenticator();
PasswordAuthentication pop = popAuthenticator.performCheck(username,password);
Session session = Session.getInstance(props, popAuthenticator);
session.setDebug(true);

// Define message
MimeMessage message = new MimeMessage(session);

// Set the from address
message.setFrom(new InternetAddress(from));

// Set the to address
//InternetAddress[] to = getTo();
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));

// Set the subject
message.setSubject("Hello JavaMail(1)");

// Set the content
message.setText("Welcome to JavaMail");

// Send message
Address at = new InternetAddress(host);
Transport t = session.getTransport(at);
System.out.println("---- user: "+username+" password: "+password);
t.connect(host,username,password);
message.saveChanges();
Address add[] = new Address[1];
add[0] = at;
t.send(message);

//Transport.send(message);
System.out.println("mail sent successfully");

}
catch(Exception e){
e.printStackTrace();
}

}
}

public class PopupAuthenticator extends Authenticator {
String username = null;
String password = null;

public PopupAuthenticator(){
}

public PasswordAuthentication performCheck(String user,String pass){
username = user;
password = pass;
return getPasswordAuthentication();
}

protected PasswordAuthentication getPasswordAuthentication()
{
System.out.println("--- returning username and password ----");
return new PasswordAuthentication(username, password);
}
}
Can anyone immediately help me.

   <<Less

Re: I am getting this error with my yahooID when i run the follwoing class!_NEWLINE_!javax.mail.AuthenticationFailedException

Posted By:   John_Zukowski  
Posted On:   Thursday, January 24, 2002 08:40 PM

The FAQ already covers issues with connecting to Yahoo.
About | Sitemap | Contact