javax.mail.AuthenticationFailedException

i use eclipse to write the code. i have import all the related jars file.

there is no compile error.

But when i run the code, i got the following message.

DEBUG: setDebug: JavaMail version 1.4ea

hhhhhhhhhhhhhhhhhhhhhhhhhhh

DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.mail.yahoo.com", port 587, isSSL false

220 smtp103.plus.mail.mud.yahoo.com ESMTP

DEBUG SMTP: connected to host "smtp.mail.yahoo.com", port: 587

EHLO tamki-zx6kuueyo

250-smtp103.plus.mail.mud.yahoo.com

250-AUTH LOGIN PLAIN XYMCOOKIE

250-PIPELINING

250 8BITMIME

DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XYMCOOKIE"

DEBUG SMTP: Found extension "PIPELINING", arg ""

DEBUG SMTP: Found extension "8BITMIME", arg ""

DEBUG SMTP: Attempt to authenticate

AUTH LOGIN

334 VXNlcm5hbWU6

Y2FybF9jc190dGs=

334 UGFzc3dvcmQ6

cTk3NTU1Njg3Mw==

535 authorization failed (#5.7.0)

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.mail.yahoo.com", port 587, isSSL false

220 smtp106.plus.mail.mud.yahoo.com ESMTP

DEBUG SMTP: connected to host "smtp.mail.yahoo.com", port: 587

EHLO tamki-zx6kuueyo

250-smtp106.plus.mail.mud.yahoo.com

250-AUTH LOGIN PLAIN XYMCOOKIE

250-PIPELINING

250 8BITMIME

DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XYMCOOKIE"

DEBUG SMTP: Found extension "PIPELINING", arg ""

DEBUG SMTP: Found extension "8BITMIME", arg ""

DEBUG SMTP: Attempt to authenticate

AUTH LOGIN

334 VXNlcm5hbWU6

Y2FybF9jc190dGs=

334 UGFzc3dvcmQ6

cTk3NTU1Njg3Mw==

535 authorization failed (#5.7.0)

javax.mail.AuthenticationFailedException

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

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

at SendMail1.send(SendMail1.java:37)

at SendMail1.main(SendMail1.java:51)

it seems that the authentication process does not succeed.

How can i fix the problem.

Here is my code.

import java.io.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

publicclass SendMail1{

publicstaticvoid send(String smtpHost,int smtpPort, String from,

String to, String subject, String content)throws AddressException,

MessagingException{

InternetAddress[] address =null;

String mailserver = smtpHost;

String user ="xxxx";

String pas ="password";

boolean sessionDebug =true;

try{

java.util.Properties props = System.getProperties();

props.put("mail.host", mailserver);

props.put("mail.transport.protocol","smtp");

props.put("mail.smtp.port",""+smtpPort);

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

SmtpAuthenticator auth =new SmtpAuthenticator(user, pas);

javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props, auth);

mailSession.setDebug(sessionDebug);

Message msg =new MimeMessage(mailSession);

msg.setFrom(new InternetAddress(from));

address = InternetAddress.parse(to,false);

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

msg.setSubject(subject);

msg.setText(content);

Transport transport = mailSession.getTransport();

transport.connect(mailserver, user, pas);

msg.saveChanges();

transport.sendMessage(msg, msg.getAllRecipients());

transport.close();

System.out.print("Transmit successfully");

}catch (MessagingException mex){

mex.printStackTrace();

}

}

publicstaticvoid main(String[] args)throws Exception{

// Send a test message

send("smtp.mail.yahoo.com", 587,"xxx@yahoo.com.hk",

"xxxx@yahoo.com.hk","re: dinner","How about at 7?");

}

}

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;

publicclass SmtpAuthenticatorextends Authenticator

{

private PasswordAuthentication password_auth;

public SmtpAuthenticator(String smtp_user, String smtp_password)

{

password_auth =new PasswordAuthentication(smtp_user, smtp_password);

}

public PasswordAuthentication getPasswordAuthentication()

{

return password_auth;

}

}

Plx help me. Thanks alot.

[6568 byte] By [carltamkia] at [2007-10-3 0:10:33]
# 1
Have you paid for the premium Yahoo service that allows you toconnect to them directly to send mail? Or are you just trying touse your free email account username and password? If so, itwon't work, as you can see.
bshannona at 2007-7-14 17:00:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
String user = "xxxx";String pas = "password";I guess u r giving ur userid as username for authentication.This works only some times.Instead of that give the whole email addressxxx@yahoo.comhope ur probs will b
Tezua at 2007-7-14 17:00:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

You donot need the premium account to send SMTP mails.

You can very well use a Mail client to send SMTP emails from Yahoo.

However you have to enable the service in your Yahoo mail account.

make sure you use AUTH command as Yahoo requires authentication.

Hope this helps you.

pradeep_agnihotria at 2007-7-14 17:00:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...