<%
'SendEmail(發(fā)送人Email,發(fā)送者,收件人Email,郵件標(biāo)題,郵件內(nèi)容,smtp服務(wù)器地址,郵件服務(wù)器驗(yàn)證密碼)
Function SendEmail(frommail,fromname,tomail,subject,content,mailserver,ServerPass)
On Error Resume Next
Set JMail = server.CreateObject("JMail.Message") '創(chuàng)建Jmail對(duì)象
JMail.Logging = True '是否使用日志
JMail.charset = "gb2312" '郵件編碼,缺省為"US-ASCII",最好加上,免得出現(xiàn)亂碼
JMail.ContentType = "text/html" '郵件的格式,text/plain為純文本型
JMail.From = frommail '發(fā)送郵件地址,最好寫郵件服務(wù)器驗(yàn)證的郵箱賬號(hào)
JMail.FromName = fromname '發(fā)送者,可以隨便填寫
JMail.AddRecipient tomail '要發(fā)送到的郵件地址
JMail.Subject = subject '郵件的標(biāo)題
JMail.Priority = 3 '郵件的優(yōu)先級(jí)
JMail.Body = content '郵件的內(nèi)容
JMail.MailServerUserName = frommail '郵件服務(wù)器驗(yàn)證賬號(hào)
JMail.MailServerPassword = ServerPass '郵件服務(wù)器驗(yàn)證密碼
JMail.Send(mailserver) '通過郵件服務(wù)器smtp發(fā)送郵件
Set JMail = Nothing '關(guān)閉對(duì)象
If Err.Number<>0 Then '錯(cuò)誤處理
SendEmail = False
Else
SendEmail = True
End If
End Function
%>
<%
'發(fā)送測(cè)試..
'以下用的是QQ郵箱的SMTP服務(wù)
'你也可以用你的QQ郵箱來發(fā)..不過QQ郵箱默認(rèn)是沒有開啟SMTP服務(wù)的
'需要自己進(jìn)入QQ郵箱賬戶開啟SMTP服務(wù)服務(wù)才能發(fā)郵件的。
'把 xxxxxx@xx.com 改成你的收件郵箱測(cè)試一下吧
dim Send
Send=SendEmail("603028644@qq.com","易天科技","xxxxxx@xx.com","我是標(biāo)題","我是內(nèi)容","smtp.qq.com","www.newxing.com")
If Send then
response.write "發(fā)送成功"
Else
response.write "發(fā)送失敗"
End If
%>