jsp发邮件出错

LLIUJAN2000 2002-04-04 11:29:11
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*,java.sql.*,java.util.Properties,java.text.*,java.util.Date,java.net.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<%@ page import="javax.mail.Transport" %>
<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.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("body"));
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage);
%>
<P>Your mail has been sent.</P>
<%}
catch(MessagingException m)
{
out.println(m.toString());
}
%>
</BODY>
</HTML>
发送处理页面对嘛,请问props.put("mail.smtp.host", "smtp.host");如何设置

...全文
51 1 打赏 收藏 举报
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
LLIUJAN2000 2002-04-04
紧急帮忙
  • 打赏
  • 举报
回复
发帖
Web 开发

8.0w+

社区成员

Java Web 开发
社区管理员
  • Web 开发社区
加入社区
帖子事件
创建了帖子
2002-04-04 11:29
社区公告
暂无公告