Jmail发信函数
<%
Dim SendStat
SendStat = Jmail("Dove.163@163.com","Test Jmail","Just a test!","US-ASCII","text/plain")
Response.Write SendStat
%>
<%
'--------------------------------------------------------------------
Function Jmail(mailTo,mailTopic,mailBody,mailCharset,mailContentType)
'--------------------------------------------------------------------
'JMail
'--------------------------------------------------------------------
'入口参数:
' mailTo 收件人email地址
' mailTopic 邮件主题
' mailBody 邮件正文(内容)
' mailCharset 邮件字符集,例如GB2312或US-ASCII
' mailContentType 邮件正文格式,例如text/plain或text/html
'返回值:
' 字符串,发送成功后返回OK,不成功返回错误信息
'使用方法:
' 1)设置好常量,即以Const开头的变量
' 2)使用类似如下代码发信
'Dim SendStat
'SendStat = Jmail("aa@163.com","测试Jmail","这是一封<br/>测试信!","GB2312","text/html")
'Response.Write SendStat
'作者:
' 午夜狂龙(Madpolice) madpolice_dong@hotmail.com 2005年6月2日版
'--------------------------------------------------------------------
'***************根据需要设置常量开始*****************
Dim ConstFromNameCn,ConstFromNameEn,ConstFrom,ConstMailDomain,ConstMailServerUserName,ConstMailServerPassword
ConstFromNameCn = ""'发信人中文姓名(发中文邮件的时候使用),例如‘张三’
ConstFromNameEn = ""'发信人英文姓名(发英文邮件的时候使用),例如‘zhangsan’
ConstFrom = ""'发信人邮件地址,例如‘Shakerd@163.com’
ConstMailDomain = ""'smtp服务器地址,例如smtp.163.com
ConstMailServerUserName = ""'smtp服务器的信箱登陆名,例如‘zhangsan’。注意要与发信人邮件地址一致!
ConstMailServerPassword = ""'smtp服务器的信箱登陆密码
'***************根据需要设置常量结束*****************
'-----------------------------以下内容无需改动------------------------------
On Error Resume Next
Dim myJmail
Set myJmail = Server.CreateObject("JMail.Message")
myJmail.Logging = True'记录日志
myJmail.ISOEncodeHeaders = False'邮件头不使用ISO-8859-1编码
myJmail.ContentTransferEncoding = "base64"'邮件编码设为base64
myJmail.AddHeader "Priority","3"'添加邮件头,不要改动!
myJmail.AddHeader "MSMail-Priority","Normal"'添加邮件头,不要改动!
myJmail.AddHeader "Mailer","Microsoft Outlook Express 6.00.2800.1437"'添加邮件头,不要改动!
myJmail.AddHeader "MimeOLE","Produced By Microsoft MimeOLE V6.00.2800.1441"'添加邮件头,不要改动!
myJmail.Charset = mailCharset
myJmail.ContentType = mailContentType
If UCase(mailCharset) = "GB2312" Then
myJmail.FromName = ConstFromNameCn
Else
myJmail.FromName = ConstFromNameEn
End If
myJmail.From = ConstFrom
myJmail.Subject = mailTopic
myJmail.Body = mailBody
myJmail.AddRecipient mailTo
myJmail.MailDomain = ConstMailDomain
myJmail.MailServerUserName = ConstMailServerUserName
myJmail.MailServerPassword = ConstMailServerPassword
myJmail.Send ConstMailDomain
myJmail.Close
Set myJmail=nothing
If Err Then
Jmail=Err.Description
Err.Clear
Else
Jmail="OK"
End If
On Error Goto 0
End Function
'--------------------------------------------------------------------
%>