有时mailto 用起来不是很方便,像下边这样
<script language="javascript">
function SendMail()
{
document.location="mailto:me@home.com;?subject=Feedback;
}
</script>
<a href="javascript:SendMail();"> Contact US </a>
所以也可以用组件发送邮件
js 发送邮件
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<script>
SendEMail('','');
/*
**infor: 要发送的邮件信息
**subject: 要发送的邮件主题
*/
function SendEMail(infor, subject)
{
var jMail = new ActiveXObject("Jmail.message");
jMail.Silent = true;
jMail.Charset = "utf-8";
jMail.FromName = "sender" //发件人
jMail.From = "anxingyu_1984@126.com"; //发送人的邮件地址
jMail.AddRecipient("axy_1984@126.com"); //收件人的邮件地址
// jMail.Subject = subject;
// jMail.Body = infor;
jMail.Subject = "test";
jMail.Body = "tests";
jMail.MailServerUserName="anxingyu_1984@126.com";
jMail.MailServerPassWord="密码";
var ret = jMail.Send("smtp.126.com");
if(ret == false)
{
alert("fail");
}
else
{
alert("success");
}
jMail.Close();
}
</script>
</BODY>
</HTML>
注册组件:
jmail.dll jmail组件,版本:4.4,安装方法:将其复制到system32目录下,在MS-DOS下执行regsvr32 Jmail.dll即可
网上下了个包,提供了很多组件,运行aaaa.bat 即可,aaaa 只注册JMail.dll