请各位帮我看看javamail的问题(本不应在这里提这类问题,但在csdn实在没人帮我解答)

03-09-17 rtm
控制台输出如下:

DEBUG SMTP: useEhlo true, useAuth true

DEBUG SMTP: trying to connect to host "smtp.21cn.com", port 25

220 21cn.com SMTP Server of AIMC 2.9.5.2 (E).

DEBUG SMTP: connected to host "smtp.21cn.com", port: 25

EHLO rtm

250-21cn.com, helo (DELAYED)

250-EXPN

250-HELP

250-8BITMIME

250-AUTH=LOGIN PLAIN

250-AUTH LOGIN PLAIN

250 XTMD

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

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

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

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

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

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

DEBUG SMTP: Attempt to authenticate

AUTH LOGIN

334 VXNlcm5hbWU6

cnRtbXRy

334 UGFzc3dvcmQ6

eGlhb2Zlbmc=

235 OK Authenticated

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

DEBUG SMTP: useEhlo true, useAuth true

javax.mail.SendFailedException: Sending failed;

nested exception is:

class javax.mail.AuthenticationFailedException

程序如下:

package mail;

import javax.mail.*;

import javax.activation.*;

import javax.mail.internet.*;

import java.util.Properties;

public class MailSend {

public static void main(String[] args) {

Properties prop = new Properties();

prop.put("mail.transport.default", "smtp");

prop.put("mail.debug", "true");

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

Session session = Session.getDefaultInstance(prop,null);

MimeMessage message = new MimeMessage(session);

try{

message.setContent("send mail test..", "text/plain");

message.setText("hehe");

message.setFrom(new InternetAddress("rtmmtr@21cn.com"));

message.setRecipient(Message.RecipientType.TO,new InternetAddress("a2602435@163.net"));

message.setSubject("mail test by rtm");

}catch(MessagingException mE){

System.err.println(mE.toString());

}

Transport transport = null;

try{

transport = session.getTransport("smtp");

}catch(NoSuchProviderException nspE){

System.err.println(nspE.toString());

}

try{

transport.connect("smtp.21cn.com", "rtmmtr", "");

transport.send(message);

transport.close();

}catch(MessagingException mE){

System.out.println(mE.toString());

}

}

}

请各位大哥指点(这里我把密码隐掉了,21cn需要认证)

rtm
2003-09-18 16:56
问题已解决,不好意思,^-^

猜你喜欢