SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: 5.7.1
代码如下:
 private static readonly string MailServer = "SHHQ-Mail12.want-want.com";//邮件服务器
    private static readonly int Port = 25;
    private static readonly string FromAddress = "[email protected]";  //发件人地址
    private static readonly string MailPassword = "sheying";
    /// <summary>
    /// 发送邮件
    /// </summary>
    public static void SendNetMail(string sendTo, string mailTitle, string mailBody)
    {
        MailMessage mailMsg = new MailMessage();
        mailMsg.IsBodyHtml = true;
        mailMsg.From = new MailAddress(FromAddress);
        mailMsg.To.Add(new MailAddress(sendTo));
        mailMsg.Subject = mailTitle;
        mailMsg.Body = mailBody;
        try
        {
            SmtpClient smtpClient = new SmtpClient(MailServer);
            smtpClient.Port = Port;
            //smtpClient.Timeout = 19999;
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new NetworkCredential(FromAddress, MailPassword);
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtpClient.Send(mailMsg);
        }
        catch (SmtpException e)
        {
            Log.Error(e.Message, e);
        }    }

解决方案 »

  1.   

    private static readonly int Port = 25;端口改一下试试.可能你发送邮件服务器中设置或要求的不一样.
      

  2.   


                System.Net.Mail.SmtpClient MailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com");
                MailClient.Port = 587;
                MailClient.EnableSsl = true;
                MailClient.Credentials = new System.Net.NetworkCredential(EmailName, EmailPassword);
                MailClient.DeliveryMethod = SmtpDeliveryMethod.Network;            MailAddress From = new MailAddress(FromAddress, FromUserName);
                MailAddress To = new MailAddress(ToAddress, ToUserName);            System.Net.Mail.MailMessage MailMsg = new MailMessage(From, To);
    gmail的示例
      

  3.   

    邮件服务器应该需要登录账号吧 代码如下:
     private static readonly string MailServer = "SHHQ-Mail12.want-want.com";//邮件服务器
      private static readonly int Port = 25;
      private static readonly string FromAddress = "[email protected]"; //发件人地址
      private static readonly string MailPassword = "sheying";
      /// <summary>
      /// 发送邮件
      /// </summary>
      public static void SendNetMail(string sendTo, string mailTitle, string mailBody)
      {
      MailMessage mailMsg = new MailMessage();
      mailMsg.IsBodyHtml = true;
      mailMsg.From = new MailAddress(FromAddress);
      mailMsg.To.Add(new MailAddress(sendTo));
      mailMsg.Subject = mailTitle;
      mailMsg.Body = mailBody;
      try
      {
      SmtpClient smtpClient = new SmtpClient(MailServer);
      smtpClient.Port = Port;
      //smtpClient.Timeout = 19999;
      smtpClient.UseDefaultCredentials = false;
      smtpClient.Credentials = new NetworkCredential(FromAddress, MailPassword);
      smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
      smtpClient.Credentials = new System.Net.NetworkCredential(userid, password);//这里的就是你要登录的账号
      smtpClient.Send(mailMsg);
      }
      catch (SmtpException e)
      {
      Log.Error(e.Message, e);
      }  }