打印本文 打印本文 关闭窗口 关闭窗口
在asp.net中发送带有smtp验证的邮件
作者:武汉SEO闵涛  文章来源:敏韬网  点击数577  更新时间:2009/4/23 10:44:27  文章录入:mintao  责任编辑:mintao

在.Net Framework 1.1中,对这一需求有了考虑,在MailMessage组件中增加了Fields集合易增加ESMTP邮件服务器中的寄送者身份验证的问题。不过,这一方法仅适用于.Net Framework 1.1,不适用于.Net Framework 1.0版本。带有寄送者身份验证的邮件发送程序如下:


<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
MailMessage mail=new MailMessage();
 mail.From="service@brookes.com";
 mail.To="brookes@brookes.com";
 mail.BodyFormat=MailFormat.Text;
 mail.Body="a test smtp mail.";
 mail.Subject="hello."
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "brookes"); //set your username here
 mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "walkor"); //set your password here
 SmtpMail.SmtpServer="lsg.moon.net";
 SmtpMail.Send(mail);
</script>

不过这种方法对sina的邮件不管用,希望大家注意

打印本文 打印本文 关闭窗口 关闭窗口