以JMail為例,這個函數可以完成發送郵件功能;
function sendMail(to,cc,bcc,subject,content)
{
var jMail=new ActiveXObject("JMAIL.Message");
jMail.silent=true;
jMail.logging=true;
jMail.Charset="gb2312";
jMail.ContentType="text/html";
jMail.From="webmaster@programmerlife.com";
jMail.MailServerUserName="webmaster";
jMail.MailServerPassword="******";
for (var i=0;i<=to.length-1;i++)
{
jMail.AddRecipient(to);
}
for (var i=0;i<=cc.length-1;i++)
{
jMail.AddRecipientCC(cc);
}
for (var i=0;i<=bcc.length-1;i++)
{
jMail.AddRecipientBCC(bcc);
}
jMail.Priority=1;
jMail.Subject=subject;
jMail.Body=content;
jMail.AddRecipientBCC(to);
jMail.AddRecipientCC(to);
var success=jMail.send("smtp.progammerlife.com");
jMail.close();
return success;
}