开发者社区> 问答> 正文

在 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文件,发出邮件,测试成功


参考:

  • http://webcheatsheet.com/asp/sending_email_asp.php
  • http://www.cnblogs.com/qiangshu/archive/2009/12/22/1629829.html

展开
收起
dongshan8 2018-06-29 18:10:39 12371 0
2 条回答
写回答
取消 提交回答
  • Re在 asp 中使用 cdo 通过远程邮件服务器发送邮件
    学习了
    2018-07-04 15:14:12
    赞同 展开评论 打赏
  • 旺旺:nectar2。
    回 1楼(痛而不言之) 的帖子
    您好,

    很高兴听到您已经解决了问题。

    在旺旺上您担到了显示邮箱发送人名字的问题,我暂时没有测试,您可以自行先在网上搜索和实践喔。
    2018-06-30 14:31:01
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS计算与存储分离架构实践 立即下载