在 asp 中使用 cdo 通过远程邮件服务器发送邮件
环境:Windows 2016 - IIS - asp, 阿里云免费邮箱账户 anqunhe@aliyun.com
过程:
1.创建 asp-sent-mail.asp 文件,内容如下,关键信息 “smtpserver”填写“smtp.aliyun.com”,“smtpserverport”填写“465”,“sendusername”填写“anqunhe@aliyun.com”,“sendpassword”填写“您的密码”,“Mail.From”填写“anqunhe@aliyun.com”
<%
Set Mail = CreateObject("CDO.Message")
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.aliyun.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="anqunhe@aliyun.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password"
Mail.Configuration.Fields.Update
Mail.Subject="Email subject"
Mail.From="anqunhe@aliyun.com"
Mail.To="liu@anqun.net"
Mail.TextBody="This is an email message."
Mail.Send
Set Mail = Nothing
%>
2.在浏览器里访问这个asp-sent-mail.asp文件,发出邮件,测试成功
参考: