javamail在jsp中调用 二,javamail在jsp中调用 二
【 tulaoshi.com - Java 】
<%@ pagetry{
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"));
newMessage.setSentDate(new Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage);
%
<PYour mail has been sent.</P
<%
}
catch(MessagingException m)
{
out.println(m.toString());
}
%
</BODY
</HTML
来源:http://www.tulaoshi.com/n/20160129/1487645.html
看过《javamail在jsp中调用 二》的人还看了以下文章 更多>>