在1.0的时候,我们是不能实现此方案的,所以大部分人选择了使用Socket底层自己重写。
在1.1的时候,MS已经提供了验证功能了。private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
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://www.systemwebmail.com/faq/3.8.aspx
在1.1的时候,MS已经提供了验证功能了。private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
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://www.systemwebmail.com/faq/3.8.aspx
有相当好的源代码!
---------------------------------------------------
[原创]EMAIL发送系统(C#+基于SMTP认证),源码开放
刚学.net时,试着做一个文章管理系统,第一次开始使用.net的System.Web.Mail消息组件,觉得很好用,而且简单。但后来发现.net自带的SmtpMail不支持SMTP认证,而且许多许多SMTP服务器不只需要登陆验证,还对MAIL From作了验证(比如263),如果和登陆用的用户名不符也不能发信,所以决定自己用C#写一个SendMail程序,其中参考了Huolx的一部分思想,取了他的一些优点。
务器拒绝了一个或多个收件人地址。服务器响应为: 550 Local user only or Authentication mechanism