这个是我的邮件发送代码,单调出来测试收发正常,但是放到网站里面就不好用了,我是。net的网站,放进去以后就出个错误
private void SendEmail()
    {
        System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
        mail.From = "[email protected]";        string mailto = email;
        mail.To = mailto;
        mail.Subject = "娉板痉浜烘墠缃戙€€瀵嗙爜鎵惧洖";
        mail.BodyFormat = System.Web.Mail.MailFormat.Text;
        mail.Body = "鎮ㄧ殑瀵嗙爜宸茬粡琚慨鏀逛负 " + password + " 璇风墷璁?";        //System.Web.Mail.SmtpMail.SmtpServer = "mail.taderhr.com";        //mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", " 32000");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "service");
        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "taderhr");        System.Web.Mail.SmtpMail.SmtpServer = "mail.taderhr.com";        System.Web.Mail.SmtpMail.Send(mail);
        Response.Write("<script>瀵嗙爜宸插埌鎮ㄧ殑閭锛岃娉ㄦ剰鏌ユ敹锛?/script>");    }

解决方案 »

  1.   

    这个是嵌入网站以后的错误页面“/”应用程序中的服务器错误。
    --------------------------------------------------------------------------------邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc15。服务器响应为 not available说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: 邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc15。服务器响应为 not available
    源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
    [COMException (0x80040211): 邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc15。服务器响应为 not available
    ][TargetInvocationException: 调用的目标发生了异常。]
       System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
       System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +436
       System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +72[HttpException (0x80004005): 邮件无法发送到 SMTP 服务器。传输错误代码为 0x800ccc15。服务器响应为 not available
    ]
       System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +119
       System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1955
       System.Web.Mail.SmtpMail.Send(MailMessage message) +131
       Personal_RegUserInformations_GetBackPassword.SendEmail() +187
       Personal_RegUserInformations_GetBackPassword.ImageButton2_Click(Object sender, ImageClickEventArgs e) +558
       System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:2.0.50727.1433; ASP.NET 版本:2.0.50727.1433