我用MailMessage和SmtpClient发送邮件,参照了很多例子,可每次总是失败,每个地方我都检查了,没有错啊?还有一点疑问就是,发送邮件不需要密码验证,这样不是可以以任何人的名义乱发邮件了吗?想不通!

解决方案 »

  1.   

    发送服务器一般都是需要验证的
    如果是你自己设的smtp服务器,检查一下设置的是否正确
      

  2.   

    用MailMessge发邮件是需要验证的,可以参考http://tintown.cnblogs.com/archive/2005/03/04/112650.aspx
    如果你可以找到不需要验证smtp服务器,那就可以乱发了,不过不需要验证的好像蛮少的
      

  3.   

    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username");
    mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password");
    为什么验证还要通过微软的服务器?可以换成别的吗?
      

  4.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Net;
    using System.Net.Mail;public partial class netuser_webproxy : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MailMessage mail = new MailMessage("from","to");
            mail.Subject = "1111111111";
            mail.Body = "2222222222222";
            SmtpClient sc = new SmtpClient("smtpserver like smtp.163.com");
            sc.Credentials = new NetworkCredential("username", "password");
            sc.Send(mail);       
        }
    }