查看: 913|回复: 0

[文章教程] 阿里云服务器不能发邮件,禁用25端口的解决办法(for asp网站)

[复制链接]
ttasp 发表于 2019-6-1 08:50:22 | 显示全部楼层 |阅读模式
阿里云发送SMTP邮件失败,阿里云服务器不能发邮件解决方法 。默认现在阿里云25端口是被屏蔽的,只能用465端口。由于jmail不能自定义端口的限制,所以只能另外想办法。不多说,代码如下,亲测成功。

  1. <%
  2. dim ttasp
  3.          ttasp=         "学员编号:" & StuNum & vbcrlf
  4.         ttasp= ttasp& "联系姓名:" & name & vbcrlf
  5.         ttasp= ttasp& "联系电话:" & Tel1 & vbcrlf
  6.         ttasp= ttasp& "联系地址:" & dq & "." &dq2  & vbcrlf
  7.         ttasp= ttasp& "年级性别:" & nj & "." & sex & vbcrlf
  8.         ttasp= ttasp& "求教学科:" & km & vbcrlf
  9.         ttasp= ttasp& "学员情况:" & qk & vbcrlf
  10.         ttasp= ttasp& "教员要求:" & yq & vbcrlf
  11.         ttasp= ttasp& "想了解该学员具体信息请点击该学员链接:" & website & "/StuDetail.asp?UserId=" &StuNum& vbcrlf
  12.         ttasp= ttasp& "发布时间:" & now & vbcrlf
  13.         
  14. '第一步: 创建一个 CDO.Message        对象
  15. dim objMail
  16. Set objMail = Server.CreateObject("CDO.Message")

  17. '第二步: 配置服务器,用户名,和相关的授权密码
  18. smtpServer ="smtp.ttasp.com" '用一个有效的邮箱替换这个范例邮件地址
  19. yourEmail ="email@ttasp.com"     '用一个有效的邮箱替换这个范例邮件地址
  20. yourPassword ="78792588"           '用一个有效的密码来替换这个范例的邮件密码

  21. '第三步:配置用于接收邮件的邮箱
  22. sendEmailTo = Agentqq1 & "@qq.com"


  23. '第四步: 设置objMail对象的配置属性
  24. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  25. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
  26. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  27. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
  28. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
  29. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = yourEmail
  30. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourPassword
  31. objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

  32. '第五步:设置完所有必要配置后,更新其设置。
  33. objMail.Configuration.Fields.Update

  34. '第六步: 准备你的电子邮件,如设置主题,正文等。
  35. objMail.From = yourEmail
  36. objMail.To = sendEmailTo

  37. objMail.Subject= "新家教编号:" & StuNum
  38. objMail.htmlBody = ttasp

  39. '第七步:发送该邮件
  40. objMail.Send
  41. Set objMail = Nothing
  42. %>
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号