调用方法:
<%call tomail("普通会员","邮箱","用户名","激活码")%>
<%
function tomail(mem,uemail,username,active)
Set jmail = Server.CreateObject("JMAIL.Message")
If JMail Is Nothing Then
jstate= "不支持"
Else
jstate= "支持"
End If
' 屏蔽例外错误,返回FALSE跟TRUE两值
smtpserver ="邮箱服务器" 'smtp.163.com 或mail.**.com
jmail.silent = true
' 启用邮件日志
jmail.logging = true
' 邮件的文字编码为国标
jmail.Charset = "GB2312"
' 邮件的格式为HTML格式
jmail.ContentType = "text/html"
' 邮件收件人的地址
jmail.AddRecipient uemail,username
'收件人称呼
jmail.FromName="中华品牌管理网"
' 发件人的E-MAIL地址
jmail.From = "邮箱名"
' 登录邮件服务器所需的用户名
jmail.MailServerUserName = "用户名" '如:username 也有是 username@**.com
' 登录邮件服务器所需的密码
jmail.MailServerPassword = "密码"
' 邮件的标题
jmail.Subject = "您好!请尽快激活您的账号!"
' 邮件的内容
jmail.Body ="<p>"&username&",您好,感谢您注册<br /> "
isgo=jmail.Send(smtpserver)
if isgo then
msg="提交成功!谢谢你的支持。"
else
msg="发送失败!请检查您的邮件地址是否填写正确。"
end if
'response.Write msg
jmail.Close()
end function
'生成激活密码
function makePassword(byVal maxLen)
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
whatsNext = Int((1 - 0 + 1) * Rnd + 0)
If whatsNext = 0 Then
'character
upper = 90
lower = 65
Else
upper = 57
lower = 48
End If
strNewPass = strNewPass & Chr(Int((upper - lower + 1) * Rnd + lower))
Next
makePassword = strNewPass
end function
%>