<html>
<head>
<title>JSP JavaMail Example </title>
</head>

<body>

<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import=" " /> 丝袜美腿av在线,三上悠亚激情av一区二区三区,欧美韩国一区二区

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

郵件發送簡單例子-jsp文件

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>

jsp技術郵件發送簡單例子-jsp文件,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 武城县| 阿合奇县| 延津县| 灌南县| 蓬莱市| 中西区| 扬州市| 北宁市| 新昌县| 宣化县| 万盛区| 仪征市| 鸡西市| 定襄县| 合山市| 朝阳市| 上饶市| 乃东县| 扶风县| 清涧县| 满洲里市| 潮安县| 共和县| 哈密市| 锦州市| 平湖市| 扎鲁特旗| 滨州市| 集安市| 祥云县| 武隆县| 邹城市| 新绛县| 水富县| 宁海县| 巫溪县| 玉林市| 马公市| 太康县| 叙永县| 汝城县|