请问如何通过反馈表单发送mail

HowHowHow 2001-07-18 09:55:25
我想做个反馈表单,客户填写信息后发送到我的mail中,
请问该如何做呢?
是不是要用javamail吗?是又该如何做
有没有更简单的方法?
...全文
117 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
leisurelph 2001-07-19
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>

<%@ page contentType="text/html;charset=gb2312"%>
<%
String from="";
String to="";
String subject="";
String body="";
String submit1="";
submit1=request.getParameter("submit1");
from=request.getParameter("from");
to=request.getParameter("to");
subject=request.getParameter("subject");
body=request.getParameter("body");
String submited="send";
%>
<html>
<head>
<title>this is my mail test</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<jsp:useBean id="sendmail" class="sendmail" scope="request">

</jsp:useBean>
<%
if(submit1!=null)
{
if (submit1.equals("send"))
{
String returnmsg;
sendmail.setFrom(from);
sendmail.setTo(to);
sendmail.setSubject(subject);
sendmail.setBody(body);
returnmsg=sendmail.send();
out.print(returnmsg);
}
}
%>
<body>
<form action="sendmail.jsp" method="post">
<P>·¢ÐÅÈË£º<INPUT name=from value=<%=from%>></P>
<P>ÊÕÐÅÈË£º<INPUT name=to value=<%=to%>></P>
<P>Ö÷Ì⣺<INPUT style="HEIGHT: 21px; WIDTH: 222px" name=subject value="<%=subject%>"></P>
<P>ÄÚÈÝ£º<TEXTAREA style="HEIGHT: 62px; WIDTH: 163px" name=body><%=body%></TEXTAREA></P>
<p><input type=submit name=submit1 value="send"></p>

</form>
</body>
</html>
javabean:

//package mail;

import java.awt.*;
import javax.swing.JPanel;
import java.io.*;
import java.util.*;
import sun.net.smtp.SmtpClient;

/**
* Title: this is my java exam
* Description: send and receive mail
* Copyright: Copyright (c) 2001
* Company: ihw
* @author lph
* @version 1.0
*/
public class sendmail {
//public class sendmail extends JPanel {
//public class sendmail implements Sericalizable{
// BorderLayout borderLayout1 = new BorderLayout();
private String to;
private String subject;
private String body;
private String from;
private String server;
//public String returnmsg;
public sendmail() {

try {
server="smtp.beij.ihw.com.cn";
from="";
to="";
body="this is lph test";
subject="java mail come";

}
catch(Exception ex) {
ex.printStackTrace();
}
}
public String getServer ()
{
return server;
}
public void setServer(String server)
{
this.server =server;
}

public String getFrom()
{
return from;
}
public void setFrom(String from) {
this.from=from;
}
public String getTo()
{
return to;
}
public void setTo(String to) {
this.to=to;
}
public String getSubject()
{
return subject;
}
public void setSubject(String subject) {
this.subject=subject;
}
public String getBody()
{
return body;
}
public void setBody(String body) {
this.body=body;
}
public String send()

{
String returnmsg;
try
{
SmtpClient sendm=new SmtpClient(server);
sendm.from(from);
sendm.to(to);
PrintStream mailOut=sendm.startMessage();
mailOut.println("From:" + from);
mailOut.println("To:" + to);
mailOut.println("Subject:" + subject);
mailOut.println(body);
mailOut.println("\r\n");
mailOut.flush();
mailOut.close();
sendm.closeServer();

return "send mail successed!";
}
catch(Exception e)
{
e.getLocalizedMessage()
//System.out.print("send mail error!");
return "send mail defailed!";

}
}

}
回复
孟子E章 2001-07-19
<form method=post action="mailto:xxx@xx.xx" enctype="text/plain">
<input name=姓名>
<input type=submit>
</form>
回复
Impylm 2001-07-18
action="mailto:xxx@xxx.xx",但是好象没有发出去,只是存在OUTLOOK的发件箱里面
回复
HowHowHow 2001-07-18
怎么没人回答?
问得太菜不好意思
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-07-18 09:55
社区公告
暂无公告