当前位置: 技术问答>java相关
请问如何通过反馈表单发送mail
来源: 互联网 发布时间:2015-01-16
本文导语: 我想做个反馈表单,客户填写信息后发送到我的mail中, 请问该如何做呢? 是不是要用javamail吗?是又该如何做 有没有更简单的方法? | this is my mail test ·¢ÐÅÈ&...
我想做个反馈表单,客户填写信息后发送到我的mail中,
请问该如何做呢?
是不是要用javamail吗?是又该如何做
有没有更简单的方法?
请问该如何做呢?
是不是要用javamail吗?是又该如何做
有没有更简单的方法?
|
this is my mail test
·¢ÐÅÈË£º
ÊÕÐÅÈË£º
Ö÷Ì⣺
ÄÚÈÝ£º
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("rn");
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!";
}
}
}
|
action="mailto:xxx@xxx.xx",但是好象没有发出去,只是存在OUTLOOK的发件箱里面
|