zoukankan      html  css  js  c++  java
  • 如何通过需要验证的邮件服务器发送邮件?

    在.NET Framework 推出以后,大家一直在为这个问题而伤脑筋。的确,在1.0的时候,我们是不能实现此方案的,大部分人选择了使用Socket底层自己重写。但是,在1.1的时候,其实Microsoft已经提供了验证功能了,只是一直没有公开。

    恰好我在读.Text 0.95的源代码的时候找到了这段代码,感觉应该提供给大家咧嘴笑脸

    private void Page_Load(object sender, System.EventArgs e)
    {
           MailMessage mail = new MailMessage();
           mail.To = "me@mycompany.com";
           mail.From = "you@yourcompany.com";
           mail.Subject = "this is a test email.";
           mail.Body = "Some text goes here";
           mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
           mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
          mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

        SmtpMail.SmtpServer = "mail.mycompany.com";  //your real server goes here
        SmtpMail.Send( mail );
    }

    参考资料:

    http://vaultpub.sourcegear.com/VaultService/VaultWeb/Blame.aspx?repid=7&path=$/Dottext/Dottext.Framework/Email/SystemMail.cs&version=1&includedversions=20 (用户名及密码为guest)

    http://www.systemwebmail.com/faq/3.8.aspx

  • 相关阅读:
    点云平台之图像算法篇
    点云平台之CloudCompare开发
    点云平台之创建工程文件
    pcl介绍
    原型讲解二:原型是干什么用的
    原型讲解一
    博主平时主要发布什么?
    蒙特利尔大学工学院流程
    ubuntu 开热点
    argos3-simulator
  • 原文地址:https://www.cnblogs.com/flyfish/p/376747.html
Copyright © 2011-2022 走看看