<%@ page language="java" contentType="text/html; charset=utf-8" import="java.util.*,javax.mail.*,javax.mail.internet.*"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>extjs examples</title>
<!-- copy right guoXXXXX.iteye.com -->
</head>
<body>
<p>
<div id="my_id"> </div>
</p>
</body>
</html>
<%
String to ="XXXXX@xmcu.cn";
String from ="XXXXX@xmcu.cn";
String server="mail.xmcu.cn";
String user="XXXXX";
String password="XXXXX2009";
try{
Properties props=new Properties ();
props.put("mail.smtp.host",server);
props.put("mail.smtp.auth","true");
props.put("mail.bebug","true");
//URLName urlName=new URLName(server);
//PasswordAuthentication pa=new PasswordAuthentication(user,password);
Session sendMailSession=Session.getDefaultInstance(props,null);
sendMailSession.setDebug(true);
//sendMailSession.setPasswordAuthentication (urlName,pa);
//SMTPTransport transport=new SMTPTransport(sendMailSession,null);
Transport transport=sendMailSession.getTransport("smtp");
Message msg = new MimeMessage(sendMailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("您好,请审批");
//msg.setHeader("X-Mailer", "msgsend");
msg.setSentDate(new Date());
Multipart mp = new MimeMultipart();
MimeBodyPart mbp = new MimeBodyPart();
// 设定邮件内容的类型为 text/plain 或 text/html
mbp.setContent("<a href='http://test.com/sdfj?sfsfjeijflskjdflsjdf' target='blank'>审批</a>","text/html;charset=GB2312");
mp.addBodyPart(mbp);
msg.setContent(mp);
// msg.setText ("<a href='fsdf'>asfsaf</a>");
transport.connect (server,user,password);
//transport.connect ();
transport.sendMessage(msg,msg.getRecipients(Message.RecipientType.TO));
}
catch(Exception ex){
ex.printStackTrace();
}
%>