邮件发送的问题
我写了个发送邮件的程序!可是测试时我用163的服务器,发送地址和接受地址一样,可是他却报错!不知道是什么原因!谁能帮我看看啊!这是我写的Servlet:public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String smtpServer = request.getParameter("txtserver");
String emailTo = request.getParameter("txtto");
String fromEmail = request.getParameter("txtfrom");
String subject = request.getParameter("txtsubject");
String body = request.getParameter("txtmessage");
try
{
Properties props = new Properties();
props.put("mail.transport.protocol","smtp");
props.put("mail.transport.host",smtpServer);
props.put("mail.transport.port","25");
Session mailsession = Session.getInstance(props);
Message msg = new MimeMessage(mailsession);
msg.setFrom(new InternetAddress(fromEmail));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(emailTo));
msg.setSentDate(new Date());
msg.setSubject(subject);
msg.setText(body);
Transport.send(msg);
msg.writeTo(System.out);
out.println("邮件已成功发送到:"+emailTo);
}
catch(Exception me)
{
System.out.println(me);
}
out.close();
}