当前位置: 代码迷 >> Java Web开发 >> 急求javamail+jsp邮件系统源码,给高分,该如何处理
  详细解决方案

急求javamail+jsp邮件系统源码,给高分,该如何处理

热度:22   发布时间:2016-04-17 14:40:32.0
急求javamail+jsp邮件系统源码,给高分
还请各位高手帮个忙
zoulei_3718@163.com

------解决方案--------------------
form.htm
========
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 邮件例程 - JavaMail - 发送HTML邮件 </title>
</head>

<body>

<table border= "0 " cellspacing= "0 " cellpadding= "0 ">
<form method= "post " action= "send.jsp ">
<tr>
<td> SMTP主机: </td>
<td> <input type= "text " name= "smtp " size= "80 "> </td>
</tr>
<tr>
<td> 发信人: </td>
<td> <input type= "text " name= "from " size= "80 "> </td>
</tr>
<tr>
<td> 收信人: </td>
<td> <input type= "text " name= "to " size= "80 "> </td>
</tr>
<tr>
<td> 抄送人: </td>
<td> <input type= "text " name= "cc " size= "80 "> </td>
</tr>
<tr>
<td> 暗送人: </td>
<td> <input type= "text " name= "bcc " size= "80 "> </td>
</tr>
<tr>
<td> 主题: </td>
<td> <input type= "text " name= "subject " size= "80 "> </td>
</tr>
<tr>
<td valign= "top "> 内容: </td>
<td> <textarea name= "body " rows= "5 " cols= "80 "> </textarea> </td>
</tr>
<tr>
<td colspan= "2 " align= "center "> <input type= "submit " value= "发送 "> </td>
</tr>
</form>
</table>

</body>
</html>

send.jsp
========
<%--
作者:何志强[hhzqq@21cn.com]
日期:2000-08-16
版本:1.0
功能:邮件例程 - JavaMail - 发送HTML邮件
--%>

<%
//变量声明
java.lang.String smtp,from,to,cc,bcc,subject,body;

//获得用户输入数据
smtp = request.getParameter( "smtp ");
from = request.getParameter( "from ");
to = request.getParameter( "to ");
cc = request.getParameter( "cc ");
bcc = request.getParameter( "bcc ");
subject = request.getParameter( "subject ");
if(subject!=null){
subject = new java.lang.String(subject.getBytes( "iso-8859-1 "));
}
body = request.getParameter( "body ");

//发送邮件
pipi.mail.HTML.send(smtp,from,to,cc,bcc,subject,body);
%>

pipi.jaf.StringDataSource.java
==============================
/*
作者:何志强[hhzqq@21cn.com]
日期:2000-08-16
功能:字符串型数据源
*/

package pipi.jaf;

public class StringDataSource implements javax.activation.DataSource{
private java.lang.String data;
private java.lang.String type;

public StringDataSource(java.lang.String data,java.lang.String type){
this.data = data;
this.type = type;
}

public java.io.InputStream getInputStream() throws java.io.IOException{
return new java.io.StringBufferInputStream(data);
}

public java.io.OutputStream getOutputStream() throws java.io.IOException{
throw new java.io.IOException( "it does not support this method now! ");