'***函数名 : SendMail
'***函数说明: JMail邮件发送函数
'***参数 :
' sFrom : 发件人的EMail地址
' sTo : 收件人的EMail地址
' sCC : 抄送人的EMail地址
' sBCC : 密件人的EMail地址
' sSubject: 邮件主题
' sBody : 邮件内容
'***返回值 : 邮件发送状态,成功返回Ture,反之返回False
Function SendMail(sFrom, sTo, sCC, sBCC, sSubject, sBody)
Dim JMail
Dim sServerAddress '邮件服务器地址
Dim sMailUserName '您的邮箱地址
Dim sMailPassword '您的邮箱密码
sServerAddress = "88.88.88.88"
sMailUserName = "lg2lg5"
sMailPassword = "www.lg2lg5.com"
Set JMail = Server.CreateObject("JMail.Message") '建立发送邮件的对象
If Err Then
Err.Clear()
Response.Write("对不起,您的服务器没有安装JMail组件,请联系管理员安装JMail组件后再次尝试。")
Exit Function
End If
JMail.silent = True 'JMail不会抛出例外错误,返回的值为FALSE跟TRUE
JMail.logging = True '启用邮件日志
JMail.ContentType = "text/html"
JMail.Charset = "UTF-8"
JMail.MailServerUserName = sMailUserName
JMail.MailServerPassword = sMailPassword
JMail.From = sFrom
JMail.AddRecipient sTo
If sCC <> "" Then JMail.AddRecipientCC sCC
If sBCC <> "" Then JMail.AddRecipientBCC sBCC
JMail.Subject = sSubject
JMail.Body = sBody
JMail.Priority = 3 '邮件的优先级,可以范围从1到5.越大的优先级约高,一般设置为3
'执行邮件发送(通过邮件服务器地址)
If Not JMail.Send(sServerAddress) Then
SendMail = False
Response.Write("<p><span style=""color:#FF0000;"">邮件发送失败,请检查您的收发件人和邮件格式是否正确,如持续出现错误,请您联系管理员!</span></p>")
Else
SendMail = True
End If
JMail.Close()
Set JMail = Nothing
End Function