Salad UN

To Taste The Salad Of Life.

« KingCMS安装在Godaddy修改记录-4电视剧流行说方言 广电总局叫停 »

KingCMS安装在Godaddy修改记录-5

[ At 2009-7-15 By Ash   5 comments ]

[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网站程序中.

有几个很讨厌的问题BodyPart.Charset = "utf-8" 这个必须存在,而且位置不能改变,不然会乱码。.Item(cdoSMTPServer) = "relay-hosting.secureserver.net" 必须是这个服务器,必须是Godaddy上的Email账户如.Item(cdoSendUserName) = "master@z-plan.org" ,注释掉的'.Item(cdoSMTPServerPort) = 25 '.Item(cdoSMTPConnectionTimeout) = 30 'Const cdoLanguagecode="http://schemas.microsoft.com/cdo/configuration/languagecode"  '.Item(cdoLanguagecode) = 0x0804 这几个部分都是一点都不需要的,加上了反而会出错。
  1. sendmail(l1,l2,l3)       
  2. '用l1传递用户姓名,l2传递用户邮箱地址,l3传递密码      
  3.      
  4. dim ch,recipient_email_list,mail       
  5. dim ret      
  6. ret = ""     
  7. recipient_email_list=l2      
  8.      
  9. ch = ch & "<html><head>"     
  10. ch = ch & "<title>在线取回密码通知信</title>"     
  11. ch = ch & "<meta http-equiv='Content-Type' content='text/html;charset=windows-1252'>"     
  12. ch = ch & "</head><body bgcolor='#ffffff'>"     
  13. ch = ch & "<table border='0' cellpadding='0' cellspacing='0' width='600' align='center'>"     
  14. ch = ch & "<tr><td style='font:Verdana;font-size:14px;color:#990000;padding:10px;' align='left'>尊敬的"&l1":<br></tr></td>"     
  15. 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>"     
  16. ch = ch & "</table></body></html>"     
  17. ch = ch & chr(13)&chr(10)      
  18.      
  19. 'on Error Resume Next      
  20.      
  21.     Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"       
  22.     Const cdoSendUsingPort=2       
  23.     Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"       
  24.     Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"       
  25.     Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"       
  26.     Const cdoBasic=1       
  27.     Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"       
  28.     Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"     
  29.     'Const cdoLanguagecode="http://schemas.microsoft.com/cdo/configuration/languagecode"      
  30.      
  31.     Dim objConfig      
  32.     Dim objMessage      
  33.     Dim Fields      
  34.      
  35.     Set objConfig = Server.CreateObject("CDO.Configuration")           
  36.     Set Fields = objConfig.Fields       
  37.      
  38.     With Fields       
  39.         .Item(cdoSendUsingMethod) = cdoSendUsingPort       
  40.         .Item(cdoSMTPServer) = "relay-hosting.secureserver.net"     
  41.         '.Item(cdoSMTPServerPort) = 25       
  42.         '.Item(cdoSMTPConnectionTimeout) = 30       
  43.         .Item(cdoSMTPAuthenticate) = cdoBasic       
  44.         .Item(cdoSendUserName) = "master@z-plan.org"     
  45.         '.Item(cdoSendPassword) = "post"     
  46.         '.Item(cdoLanguagecode) = 0x0804      
  47.         .Update       
  48.     End With       
  49.      
  50.     Set objMessage = Server.CreateObject("CDO.Message")       
  51.     Set objMessage.Configuration = objConfig       
  52.           
  53.      
  54.     With objMessage       
  55.         .To = recipient_email_list      
  56.         .From = "master@z-plan.org"     
  57.         .BodyPart.Charset = "utf-8"     
  58.         .Subject = "在线取回密码通知信"     
  59.         .HTMLBody = ch      
  60.         .Send      
  61.         if Err.Number = 0 then       
  62.         Response.Write "ok:邮件发送成功。"     
  63.         else      
  64.         Response.Write "fail:邮件发送出错,错误原因<font color=ff0000>"&Err.Description"</font>"     
  65.         end If     
  66.         Err.Clear      
  67.     End With       
  68.      
  69.      
  70.     Set Fields = Nothing       
  71.     Set objMessage = Nothing       
  72.     Set objConfig = Nothing        
  73.       
  74. end Function     

 

 

上面的代码测试是没有错误了,正常运行。

 

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Code detection by Codefense

Copyright 2008 www.s-un.cn. Some Rights Reserved.