如何解决Message = Service不可用,关闭传输通道。服务器响应如下:4.3.2服务不可用

时间:2017-07-28 10:27:28

标签: c# smtp

C#代码向后发送邮件给不同的用户。我收到错误消息=服务不可用,关闭传输通道。服务器响应为:4.3.2服务不可用

SqlCommand cmd1 = new SqlCommand("select Email,Password from Login where Email =@email", con);
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress("abc@xxx.com");//Email will be sent through this Mail
                msg.To.Add(SEmail_Display.Text);//A mail will be sent to the address carried from previous page.
                msg.Subject = " Recover your Password";
                msg.Body = ("Your Username is:" + Email + "<br/><br/>" + "Your Password is:" + Password);
                msg.IsBodyHtml = true;

                SmtpClient smt = new SmtpClient();
                smt.Host = "mail.yash.com";
                System.Net.NetworkCredential ntwd = new NetworkCredential();
                ntwd.UserName = "gd.mk"; //Credentials to access mail 
                ntwd.Password = "myPassword";  
                smt.UseDefaultCredentials = true;
                smt.Credentials = ntwd;

                smt.Port = 587;
                smt.EnableSsl = true;
                smt.Send(msg);

0 个答案:

没有答案