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

<body>

<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import=" " /> 久久精品国产免费观看,在线一区日本视频,国产精品久久久久久久免费软件

色尼玛亚洲综合影院,亚洲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文件,轉載需保留來源!

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

主站蜘蛛池模板: 贵溪市| 固安县| 获嘉县| 潍坊市| 武邑县| 肥东县| 玉环县| 怀仁县| 南华县| 南城县| 英吉沙县| 汤原县| 沾益县| 随州市| 昌吉市| 六盘水市| 绩溪县| 白水县| 石泉县| 白山市| 邵武市| 岗巴县| 南涧| 都匀市| 鄯善县| 高阳县| 社会| 加查县| 日土县| 临海市| 峨边| 民县| 大名县| 莱西市| 垣曲县| 太仓市| 定南县| 舟山市| 鄄城县| 衢州市| 阳原县|