using System.Net.Mail;
        MailMessage mm = new MailMessage();
        mm.From =new MailAddress("[email protected]");
        mm.To.Add(new MailAddress("[email protected]"));
        mm.Subject = “123”;
        mm.Body = “123”; 
        // HTML格式
        mm.IsBodyHtml = true;
        SmtpClient sc = new SmtpClient();
        sc.Host = "smtp."+mm.From.Host;
        sc.Port = 25;
        sc.Credentials = new NetworkCredential("[email protected]", "123456");
        try
        {
            sc.Send(mm);
            Response.Write("ok");
        }
        catch (Exception ex)
        {
            // 与smtp相关的错误
            if (ex is SmtpException)
            {
                // ex.ToString();
                Response.Write(ex.Message);
            }
            else
            {
                Response.Write(ex.ToString());
            }
        }
会报以下错误:
SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: Authentication required 
谁知道SMTP的身份验证啊
不要给我下面的,因为我也试过还是要验证
using System.Web.Mail;
        MailMessage mail = new MailMessage();
        mail.From = "[email protected]";
        mail.To = "[email protected]";
        mail.Subject = ".net email";
        mail.BodyFormat = MailFormat.Html;
        mail.Body = "go go go";
        SmtpMail.SmtpServer = "smtp.qq.com";
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxxxxx");
        SmtpMail.Send(mail);
高手们告诉我下啊、、、、、、、、、、、、、、

解决方案 »

  1.   

       /// <summary>
        /// 发送用户账户激活邮件
        /// </summary>
        /// <param name="strSmtpServer">邮件发送服务器</param>
        /// <param name="strFrom">发件人账号</param>
        /// <param name="strFromPass">发件人密码</param>
        /// <param name="strto">收件人账号</param>
        /// <param name="strSubject">邮件主题</param>
        /// <param name="strBody">邮件内容</param>
        public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
        {
            SmtpClient client = new SmtpClient(strSmtpServer);
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(strFrom, strFromPass);
            client.DeliveryMethod = SmtpDeliveryMethod.Network;        MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody);
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.IsBodyHtml = true;
            client.Send(message);
        }你没有发件人邮箱密码……
      

  2.   

    sc.Credentials = new NetworkCredential("[email protected]", "123456");这就是发件人的账号和密码 ~_~ !!!
      

  3.   

    SmtpMail.SmtpServer = "smtp.sina.cn";
    传错了,改下