动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   Asp → 阅读文章

 邮件发送简单例子-jsp文件

作者来源: 
阅读 1348 人次 , 2006-3-29 4:22:00 


mailexample.jsp

<html>
<head>
<title>jsp javamail example </title>
</head>

<body>

<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>

<%
string host = "yourmailhost";
string to = request.getparameter("to");
string from = request.getparameter("from");
string subject = request.getparameter("subject");
string messagetext = request.getparameter("body");
boolean sessiondebug = false;

// create some properties and get the default session.
properties props = system.getproperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");

session mailsession = session.getdefaultinstance(props, null);

// set debug on the session so we can see what is going on
// passing false will not echo debug info, and passing true
// will.
mailsession.setdebug(sessiondebug);

// instantiate a new mimemessage and fill it with the
// required information.
message msg = new mimemessage(mailsession);

msg.setfrom(new internetaddress(from));
internetaddress[] address = {new internetaddress(to)};
msg.setrecipients(message.recipienttype.to, address);
msg.setsubject(subject);
msg.setsentdate(new date());
msg.settext(messagetext);

// hand the message to the default transport service
// for delivery.
transport.send(msg);

out.println("mail was sent to " + to);
out.println(" from " + from);
out.println(" using host " + host + ".");

%>
</table>
</body>
</html>

 本文Tags邮件  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:jsp计数器-jsp文件
· 下一篇:邮件发送简单例子-html文件
· 几个常用的小函数2
· 使用xmldom在服务器端生成静态html页面
· ASP程序界面的多语言支持
· 堵住ASP漏洞
· 正则表达式简介(微软)--8.特殊字符


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077