error when I try to access my yahoo mailbox

I am using JavaMail for accesing my yahoo mailbox.

I get the following error when I try to access my mailbox

Exception :: javax.mail.AuthenticationFailedException: Error logging in.

Session session = Session.getInstance(properties,new Authenticator()

{

public PasswordAuthentication getPasswordAuthentication()

{

String username = getUser();

String password = getPassword();

return new PasswordAuthentication(username,password);

}

});

Store store = session.getStore("pop3");

store.connect(getPopHost(),user,password);

please any one help me.

i thinked error problem in

Store store = session.getStore("pop3");

store.connect(getPopHost(),user,password);

any of this lines.

please tell ur sugestions.

thanks in advance.

[852 byte] By [Senza] at [2007-10-2 14:27:07]
# 1

try it.

public class SendMailUsingAuthentication

{

private static final String SMTP_HOST_NAME = "myserver.smtphost.com";

private static final String SMTP_AUTH_USER = "myusername";

private static final String SMTP_AUTH_PWD = "mypwd";

private static final String emailMsgTxt= "a message.";

private static final String emailSubjectTxt = "a subject";

private static final String emailFromAddress = "aaa@yahoo.com";

// Add List of Email address to who email needs to be sent to

private static final String[] emailList = {"bbb@yahoo.com", "ccc@yahoo.com"};

public static void main(String args[]) throws Exception

{

SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();

smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);

System.out.println("Sucessfully Sent mail to All Users");

}

public void postMail( String recipients[ ], String subject,

String message , String from) throws MessagingException

{

boolean debug = false;

//Set the host smtp address

Properties props = new Properties();

props.put("mail.smtp.host", SMTP_HOST_NAME);

props.put("mail.smtp.auth", "true");

Authenticator auth = new SMTPAuthenticator();

Session session = Session.getDefaultInstance(props, auth);

session.setDebug(debug);

// create a message

Message msg = new MimeMessage(session);

// set the from and to address

InternetAddress addressFrom = new InternetAddress(from);

msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];

for (int i = 0; i < recipients.length; i++)

{

addressTo[i] = new InternetAddress(recipients[i]);

}

msg.setRecipients(Message.RecipientType.TO, addressTo);

// Setting the Subject and Content Type

msg.setSubject(subject);

msg.setContent(message, "text/plain");

Transport.send(msg);

}

/**

* SimpleAuthenticator is used to do simple authentication

* when the SMTP server requires it.

*/

private class SMTPAuthenticator extends javax.mail.Authenticator

{

public PasswordAuthentication getPasswordAuthentication()

{

String username = SMTP_AUTH_USER;

String password = SMTP_AUTH_PWD;

return new PasswordAuthentication(username, password);

}

}

}

leoncinaa at 2007-7-13 12:47:27 > top of Java-index,Java Essentials,Java Programming...