发帖    主题    评论    推荐    标签    作者    订阅    查搜    注册   登陆   关注
 
面向对象 设计模式 领域驱动设计 企业架构 框架 开发教程 微服务 CQRS 扩展性 并发编程 事件溯源 分布式 SOA

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

rtm
2003-09-17 10:31
赞助商链接

控制台输出如下:

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

问题已解决,不好意思,^-^

赞助商链接

赞助商链接

返回顶部

移动版 关于本站 使用帮助 联系反馈 最佳分辨率1366x768
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-20 jdon.com