初学者所碰到的javamail问题~~~~~~~~

zhaohh 2004-07-09 08:30:40
我超了段代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.lang.*" errorPage="" %>
<%@ page import="javax.mail.*,javax.mail.internet.*,javax.activation.*,java.util.*"%>
<html>
<head>
<TITLE>
JSP meets JavaMail, what a sweet combo.</TITLE>
</head><body>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;

sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.163.com");
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from")));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(request.getParameter ("to")));
newMessage.setSubject(request.getParameter("subject"));
newMessage.setSentDate(new java.util.Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
store = sendMailSession.getStore("pop3");
store.connect("pop3.163.com","用户名","密码");
Transport.send(newMessage);
store.close();
%>
<P>Your mail has been sent.</P>
<%
}catch(MessagingException m)
{
out.println(m.toString());
}
%></body></html>

运行的时候出现如下错误提示:
javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: 553 You are not authorized to send mail as >, authentication is required
请为各为大虾如何解决!
...全文
153 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaohh 2004-07-09
  • 打赏
  • 举报
回复
不能下载
liusoft 2004-07-09
  • 打赏
  • 举报
回复
http://www.javayou.com/showlog.jspe?cat_id=-1&log_id=136

看看这篇文章吧
zhaohh 2004-07-09
  • 打赏
  • 举报
回复
网络连接没问题,防火墙更是没有装!
矜持的射手 2004-07-09
  • 打赏
  • 举报
回复
网络连接是否成功,或者你是否开了防火墙?
zhaohh 2004-07-09
  • 打赏
  • 举报
回复
加了这句话后
出现如下错误
javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.AuthenticationFailedException
yjgx007 2004-07-09
  • 打赏
  • 举报
回复
props.put("mail.smtp.auth", "true");
zhaohh 2004-07-09
  • 打赏
  • 举报
回复
能不能提供详细点?
jinsfree 2004-07-09
  • 打赏
  • 举报
回复
authorized记得好像有个函数设置为ture具体忘记了,你可以找找资料

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧