[KingCMS安装在Godaddy修改记录-4] [KingCMS安装在Godaddy修改记录-3] [KingCMS安装在Godaddy修改记录-2] [KingCMS安装在Godaddy修改记录]
因为需要用到在线取回密码的功能,原来的服务器有AspMail,非常好用,转移到Godaddy后不能用了,网上搜索的代码也说的非常不清楚,自己参照着改了一个。最头疼的是编码问题,我这里用的是Utf-8,如果要用Gb2312,首先是文件就是要GB2312的,然后才设置Email的编码格式。Godaddy的服务器用的 CDO.Message, 而且不能用其他服务器的邮箱,比如SMTP.QQ.com。 下面的解释我写的很清楚了,用在什么地方可能要自己去修改了,这个其实是不属于KingCMS的代码,是另加的功能。但同样也可以用在其他的ASP网站程序中.
- sendmail(l1,l2,l3)
- '用l1传递用户姓名,l2传递用户邮箱地址,l3传递密码
- dim ch,recipient_email_list,mail
- dim ret
- ret = ""
- recipient_email_list=l2
- ch = ch & "<html><head>"
- ch = ch & "<title>在线取回密码通知信</title>"
- ch = ch & "<meta http-equiv='Content-Type' content='text/html;charset=windows-1252'>"
- ch = ch & "</head><body bgcolor='#ffffff'>"
- ch = ch & "<table border='0' cellpadding='0' cellspacing='0' width='600' align='center'>"
- ch = ch & "<tr><td style='font:Verdana;font-size:14px;color:#990000;padding:10px;' align='left'>尊敬的"&l1":<br></tr></td>"
- ch = ch & "<tr><td height='30' style='font:Verdana;font-size:12px;color:#99999;padding:10px;' align='left'>您好!您已经提交了取回密码的申请,您的密码为"&l3"。<br />请尽快登陆后台修改您的个人信息。<br /><br /><br />此邮件为系统自动发送,请莫回复。</td></tr>"
- ch = ch & "</table></body></html>"
- ch = ch & chr(13)&chr(10)
- 'on Error Resume Next
- Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
- Const cdoSendUsingPort=2
- Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
- Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
- Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
- Const cdoBasic=1
- Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
- Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"
- 'Const cdoLanguagecode="http://schemas.microsoft.com/cdo/configuration/languagecode"
- Dim objConfig
- Dim objMessage
- Dim Fields
- Set objConfig = Server.CreateObject("CDO.Configuration")
- Set Fields = objConfig.Fields
- With Fields
- .Item(cdoSendUsingMethod) = cdoSendUsingPort
- .Item(cdoSMTPServer) = "relay-hosting.secureserver.net"
- '.Item(cdoSMTPServerPort) = 25
- '.Item(cdoSMTPConnectionTimeout) = 30
- .Item(cdoSMTPAuthenticate) = cdoBasic
- .Item(cdoSendUserName) = "master@z-plan.org"
- '.Item(cdoSendPassword) = "post"
- '.Item(cdoLanguagecode) = 0x0804
- .Update
- End With
- Set objMessage = Server.CreateObject("CDO.Message")
- Set objMessage.Configuration = objConfig
- With objMessage
- .To = recipient_email_list
- .From = "master@z-plan.org"
- .BodyPart.Charset = "utf-8"
- .Subject = "在线取回密码通知信"
- .HTMLBody = ch
- .Send
- if Err.Number = 0 then
- Response.Write "ok:邮件发送成功。"
- else
- Response.Write "fail:邮件发送出错,错误原因<font color=ff0000>"&Err.Description"</font>"
- end If
- Err.Clear
- End With
- Set Fields = Nothing
- Set objMessage = Nothing
- Set objConfig = Nothing
- end Function
上面的代码测试是没有错误了,正常运行。