关于JAVAMAIL发邮件问题! 救助啦^^
java6 2001-09-09 02:36:10
请先看一下此发送JAVAMAIL的JSP程序:
<%@ page import= " javax.mail.*, javax.mail.internet.*, javax.activation.*, java.util.*"%>
<html>
<head>
<title> JavaMail 电子邮件发送系统 </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.sohu.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 Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
transport.connect("smtp.sohu.com","wang76_cn","764688");
transport.send(newMessage);
%>
<p> 你的邮件已发送,请返回。 <p>
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%>
</body>
</html>
我从表单中提交from: wang_cn@sohu.com
to: whsu@sina.com
怎么出错呀:
javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: 505 Client was not authenticated