| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 799 人关注过本帖
标题:[求助]在编写JavaMail出现"需要认证要求"的错误
只看楼主 加入收藏
lhlzist
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-3-30
收藏
 问题点数:0 回复次数:1 
[求助]在编写JavaMail出现"需要认证要求"的错误

原代码如下:
sendmail.html页面
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>利用java发送电子邮件</title>
</head>

<body>
<center>利用java发送电子邮件</center>
<hr>

<form action="sendmail.jsp" method="post">
收信人邮箱:
<input type="text" name="to" size="30"><br>

寄信人邮箱:
<input type="text" name="from" size="30"><br>

主题:&nbsp;&nbsp; &nbsp; &nbsp;
<input type="text" name="subject" size="30"><br>
正题:<br>
<textarea cols="40" rows="8" name="body">
</textarea><br>
<input type="submit" name="submit" value="发送">
<input type="reset" name="reset" value="重置">
</form>
</body>
</html>


sendmail.jsp
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*,javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JSP Javamail的使用</title>
</head>

<body>
<%
request.setCharacterEncoding("gb2312");
String host="220.181.12.16";
String to=request.getParameter("to");
String from = request.getParameter("from");
String subject=request.getParameter("subject");
String body=request.getParameter("body");

boolean sessionDebug=false;

java.util.Properties props=System.getProperties();
props.put("mail.host",host);
props.put("mail.transport.protocol","smtp");

javax.mail.Session mailSession=javax.mail.Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);

Message msg =new MimeMessage(mailSession);
//设置发信人
msg.setFrom(new InternetAddress(from));
//设置收信人,可以有多个收信人
InternetAddress[] address={new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO,address);

//设置主题
msg.setSubject(subject);
//设置发信时间
msg.setSentDate(new Date());
//设置邮件MIME type
msg.setText(body);
//邮件发送
Transport.send(msg);

%>
电子邮件已发送至:<%= to %><br>
从:<%= from %><br>
使用主机:<%= host %>
邮件主题:<%= subject %>
邮件内容:<%= body %>
</body>
</html>


出现下面的错误:

javax.servlet.ServletException: 553 authentication is required,smtp9,wKjAEDLATB1XFTVEWQ5bGw==.14497S2

	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
	org.apache.jsp.study.sendmail_jsp._jspService(sendmail_jsp.java:115)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

com.sun.mail.smtp.SMTPSendFailedException: 553 authentication is required,smtp9,wKjAEDLATB1XFTVEWQ5bGw==.14497S2

	com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1333)
	com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:906)
	com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:535)
	javax.mail.Transport.send0(Transport.java:151)
	javax.mail.Transport.send(Transport.java:80)
	org.apache.jsp.study.sendmail_jsp._jspService(sendmail_jsp.java:89)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



谢谢大家帮忙看下该怎么改啊!!
搜索更多相关主题的帖子: JavaMail 电子邮件 java dtd 
2006-04-06 21:55
halugen
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-5-15
收藏
得分:0 
没密码呀!做个有密码的。
2006-05-15 09:28
快速回复:[求助]在编写JavaMail出现"需要认证要求"的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026707 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved