先前我曾经介绍过一个Z-Blog发送邮件插件的插件,可以用于发送邮件到邮件列表,用于邮件订阅博客。其实这个插件还有一个功能,就是自动同步日志到Google Blogspot和MSN Live Spaces上面的博客。
由于Google Blogspot和MSN Live Spaces都支持电子邮件的发布,因此将发布邮件地址加入到插件的收信人,并以逗号分隔即可,经过我的测试,原始的程序发送过程中,中文会出现乱码,我将该插件代码修改了一下,经过我的实际测试,发送到Blogspot上的邮件已经没有乱码了,以下是修改后的include.asp文件,请替换修改即可。
Const MailPost_MailTo="email1@blogger.com,email2@spaces.live.com"
Const MailPost_MailFrom="webmaster@williamlong.info"
Const MailPost_SmtpServer="127.0.0.1"
Const MailPost_uname=""
Const MailPost_upass=""
Dim MailPost_objArticle
Dim isNew
'注册插件
Call RegisterPlugin("MailPost","ActivePlugin_MailPost")
'具体的接口挂接
Function ActivePlugin_MailPost()
'挂上接口
Call Add_Action_Plugin("Action_Plugin_ArticlePst_Begin","Call MailPost_Main()")
End Function
Function MailPost_getArticle(ByRef objArticle)
Set MailPost_objArticle=objArticle
If MailPost_objArticle.ID = "0" Then
isNew=True
Else
isNew=False
End If
End Function
Function MailPost_gotoPingTB()
If isNew Then
Call Send_Email(MailPost_SmtpServer,MailPost_MailFrom,MailPost_uname,MailPost_upass,MailPost_MailTo,"MailPost",MailPost_objArticle.title,MailPost_objArticle.content & " ")
End If
End Function
Function MailPost_Main()
Call Add_Filter_Plugin("Filter_Plugin_PostArticle_Core","MailPost_getArticle")
Call Add_Action_Plugin("Action_Plugin_ArticlePst_Succeed","Call MailPost_gotoPingTB()")
End Function
Function Send_Email(smtpHost,FromEmail,smtpUser,smtpPass,mailTo,FromName,subject,content)
'处理收件人
If InStr(mailTo,",")<1 Then
mailTo=mailTo &","
End If
Dim tos,i
tos = Split(mailTo,",")
Dim jmail
Set jmail = Server.CreateObject("JMAIL.Message")
jmail.silent = true
jmail.logging = true
'jmail.ContentType = "text/html"
jmail.Charset = "GB2312"
jmail.ContentTransferEncoding = "base64"
Jmail.ISOEncodeHeaders = True
For i = LBound(tos) To UBound(tos)
If tos(i)<>"" Then jmail.AddRecipient tos(i)
Next
jmail.From = FromEmail
jmail.FromName = FromName
jmail.Subject = subject
jmail.HTMLBody = content
jmail.Priority = 1
jmail.MailServerUserName = smtpUser
jmail.MailServerPassword = smtpPass
jmail.Send(smtpHost)
jmail.Close()
End Function
Const MailPost_MailFrom="webmaster@williamlong.info"
Const MailPost_SmtpServer="127.0.0.1"
Const MailPost_uname=""
Const MailPost_upass=""
Dim MailPost_objArticle
Dim isNew
'注册插件
Call RegisterPlugin("MailPost","ActivePlugin_MailPost")
'具体的接口挂接
Function ActivePlugin_MailPost()
'挂上接口
Call Add_Action_Plugin("Action_Plugin_ArticlePst_Begin","Call MailPost_Main()")
End Function
Function MailPost_getArticle(ByRef objArticle)
Set MailPost_objArticle=objArticle
If MailPost_objArticle.ID = "0" Then
isNew=True
Else
isNew=False
End If
End Function
Function MailPost_gotoPingTB()
If isNew Then
Call Send_Email(MailPost_SmtpServer,MailPost_MailFrom,MailPost_uname,MailPost_upass,MailPost_MailTo,"MailPost",MailPost_objArticle.title,MailPost_objArticle.content & " ")
End If
End Function
Function MailPost_Main()
Call Add_Filter_Plugin("Filter_Plugin_PostArticle_Core","MailPost_getArticle")
Call Add_Action_Plugin("Action_Plugin_ArticlePst_Succeed","Call MailPost_gotoPingTB()")
End Function
Function Send_Email(smtpHost,FromEmail,smtpUser,smtpPass,mailTo,FromName,subject,content)
'处理收件人
If InStr(mailTo,",")<1 Then
mailTo=mailTo &","
End If
Dim tos,i
tos = Split(mailTo,",")
Dim jmail
Set jmail = Server.CreateObject("JMAIL.Message")
jmail.silent = true
jmail.logging = true
'jmail.ContentType = "text/html"
jmail.Charset = "GB2312"
jmail.ContentTransferEncoding = "base64"
Jmail.ISOEncodeHeaders = True
For i = LBound(tos) To UBound(tos)
If tos(i)<>"" Then jmail.AddRecipient tos(i)
Next
jmail.From = FromEmail
jmail.FromName = FromName
jmail.Subject = subject
jmail.HTMLBody = content
jmail.Priority = 1
jmail.MailServerUserName = smtpUser
jmail.MailServerPassword = smtpPass
jmail.Send(smtpHost)
jmail.Close()
End Function
没有评论:
发表评论