文章作者 100test 发表时间 2007:09:11 11:44:25
来源 100Test.Com百考试题网
javamail在jsp中调用 二
<%@ page
import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*"
%>
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")).
newMessage.setSentDate(new Date()).
newMessage.setText(request.getParameter("text")).
transport = sendMailSession.getTransport("smtp").
transport.send(newMessage).
%>
Your mail has been sent.