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");如何设置

...全文
9 点赞 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
LLIUJAN2000 2002-04-04
紧急帮忙
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告