1、QQ邮箱必须打开smtp(可能需要发短信验证才能开通),会得到16位授权码,这个授权码当作密码配置在脚本中。
2、脚本是利用CDO对象进行发邮件的,要注意各个属性必须用小写字母写。
3、脚本中的端口号必须465不能用25(其它非ssl邮箱可以配置25的)、脚本中需要配置开ssl
代码转自 thinkai的博客 thinkai.net/p/tag/发邮件
Mail("sunwind<1576157@qq.com>","1576157@qq.com","测试主题","测试内容<br>124567")
return
Mail(from,to,subject,content,attach*){
cdoSendUsingPort:=2
cdoBasic:=1
NameSpace := "http://schemas.microsoft.com/cdo/configuration/"
Email := ComObjCreate("CDO.Message")
Email.From := from
Email.To := to
;~ Email.Bcc := "1576157@qq.com"
Email.Subject := subject
Email.Htmlbody := content
;~ Email.Textbody := content
for k,v in attach
{
IfExist, % v
Email.AddAttachment(v)
}
Email.Configuration.Fields.Item(NameSpace "sendusing") :=2
Email.Configuration.Fields.Item(NameSpace "smtpserver") := "smtp.qq.com" ;SMTP服务器地址
Email.Configuration.Fields.Item(NameSpace "smtpserverport") := 465
Email.Configuration.Fields.Item(NameSpace "connectiontimeout)") := 10
Email.Configuration.Fields.Item(NameSpace "smtpauthenticate") :=1
Email.Configuration.Fields.Item(NameSpace "smtpusessl") :=true
Email.Configuration.Fields.Item(NameSpace "sendusername") := "1576157@qq.com" ;邮箱账号
Email.Configuration.Fields.Item(NameSpace "sendpassword") := "16位授权码" ;qq邮箱授权码
Email.Configuration.Fields.update
Email.Send
}