一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

javamail在jsp中调用

时间:2022-07-02 18:11:36 编辑:袖梨 来源:一聚教程网

一、
>

jsp" method="post">



To:



From:





Subject:





Message:










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


JSP meets Java</a>Mail, what a sweet combo.


<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
props.put("mail.smtp.host", "smtp.jspinsider.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"));

热门栏目