可以将用户的邮箱作为名字连接的参数
将你公司邮箱,用户名,密码,内容作为常量通过:
<%@ page language="java" contentType="text/html;charset=gb2312" %>
<%@ page import=" javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*"%>
<html>
<head>
<TITLE>JSP meets JavaMail, what a sweet combo.</TITLE>
</head>
<body>
<%
try{
Properties props = new Properties();
Session sendMailSession;
Store store;
Transport transport; 
sendMailSession = Session.getDefaultInstance(props);
sendMailSession.setDebug(true);
props.put("mail.smtp.host", "smtp.sina.com.cn");//换成你的邮件服务器的smtp
props.put("mail.smtp.auth", "true"); 
transport = sendMailSession.getTransport("smtp");
transport.connect("smtp.sina.com.cn",新浪帐号,帐号密码); //换成你的邮件服务器的smtp,帐号,密码Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from")));
newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress ( request.getParameter ("to")));//获得的参数:要发送的邮箱地址
newMessage.setSubject("标题");
newMessage.setSentDate(new Date());
newMessage.setText("内容");transport.send(newMessage);
transport.close();
%>
<P>Your mail has been sent.</P>
<%
}catch(MessagingException m)
{
out.println(m.toString());
}
%>
</body>
</html>