ASP使用Jmail发送邮件代码,亲测可用
<%
function sendmail(rec_email)
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" '''' 邮件字符集
JMail.FromName = "golbz" '''' 发送者姓名
JMail.Subject = "邮件主题" '''' 邮件主题
JMail.Priority = 3
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.AddRecipient(rec_email)
JMail.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""></head><body>邮件内容</body></html>" '''' 邮件内容
JMail.Body = "邮件采用了HTML格式,但是您的邮件查看软件可能不支持"
JMail.From = "" '''' 发送者地址
JMail.MailServerUserName = "" '''' 身份验证的用户名
JMail.MailServerPassword = "" '''' 身份验证的密码
JMail.Send("smtp.126.com") '''' smtp服务器
if err.number<>0 then
response.Write("发送失败!")
else
response.Write("发送成功!")
end if
JMail.Close()
Set JMail = Nothing
end function
%>
注:发送者地址,身份验证的用户名和身份验证的密码不能为空!
调用:sendmail(xxx@xxx.com)