利用javascript发送邮件

我们在做web应用程序时,有时客户希望发送邮件,这时我们可以用jmail结合javascript发送邮件.具体做法如下:
将jmail dll文件添加到项目中,然后在head中添加如下脚本函数就ok

/*
**infor: 要发送的邮件信息
**subject: 要发送的邮件主题
*/
function SendEMail(infor, subject)
{
var jMail = new ActiveXObject("Jmail.message");
jMail.Silent = true;
jMail.Charset = "gb2312";
jMail.FromName = "sender" //发件人
jMail.From = "
[email protected] "; //发送人的邮件地址
jMail.AddRecipient("
[email protected] "); //收件人的邮件地址
jMail.Subject =subject;
jMail.Body =infor;
jMail.MailServerUserName="发件人邮箱登陆名";
jMail.MailServerPassWord="发件人邮箱登陆密码";
var ret = jMail.Send("smtp.163.com");
if(ret == false)
{
alert("fail");
}
else
{
alert("success");
}
jMail.Close();

}

你可能感兴趣的:(JavaScript)