dcsimg
I getting javax.mail.AuthenticationFailedException!_NEWLINE_!when i run my MailExample with yahooID. cam help me
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, January 21, 2002 07:13 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; int q = from.indexOf("@"); String username = from.substring(0,q).trim(); String password = "narendra"; try{ // Get system properties // Setup mail server Properties p   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;

int q = from.indexOf("@");
String username = from.substring(0,q).trim();
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 getting javax.mail.AuthenticationFailedException!_NEWLINE_!when i run my MailExample with yahooID. cam help me

Posted By:   Sharona_Feinberg  
Posted On:   Tuesday, January 22, 2002 08:34 AM

yahoo.com is incorrect you should use either an IP address or a DNS name,


try one of the following :


mx4.mail.yahoo.com


mx1.mail.yahoo.com


mx2.mail.yahoo.com


how to get the DNS name ?


go to the command line



nslook


set q = any


yahoo.com



good luck

About | Sitemap | Contact