با سلام و خسته نباشید
من از کدهای فرستادن ایمیل بازیابی کلمه عبور در asp.net که در سایت برنامه نویسان قرار دادین استفاده کردم ولی خطای زیر را میدهد؟
ممنون میشم در مورد علت خطا و رفع آن راهنمایی فرمائید.
با تشکر فراوان
Server Error in '/' Application. The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at Source Error: Line 57: smtp.Credentials = NetworkCred; Line 58: smtp.Port = 587; Line 59: smtp.Send(mm); Line 60: lblMessage.ForeColor = Color.Green; Line 61: lblMessage.Text = "Password has been sent to your email address.";
اگر اشتباه نکنم شما از Gmail برای ارسال استفاده کردید که گوگل هم IP ارسال کننده رو مسدود میکنه
وارد لینک زیر بشوید و Enable را انتخاب کنید
سلام ،هنوز داره به این قسمت smtp.Send(mm); خطا می دهد.
لطفا راهنمایی کنید.با تشکر
Server Error in '/' Application.
Unable to read data from the transport connection: net_io_connectionclosed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. Source Error: Line 57: smtp.Credentials = NetworkCred; Line 58: smtp.Port = 587; Line 59: smtp.Send(mm); Line 60: lblMessage.ForeColor = Color.Green; Line 61: lblMessage.Text = "Password has been sent to your email address.";
نوع خطا تغییر کرد
لطفا کد را کامل قرار دهید تا بررسی کنیم
string username = string.Empty; string password = string.Empty; string constr = ConfigurationManager.ConnectionStrings["9dayConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("SELECT username, password FROM admin WHERE Email = @Email")) { cmd.Parameters.AddWithValue("@Email", TextBox1.Text.Trim()); cmd.Connection = con; con.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { if (sdr.Read()) { username = sdr["username"].ToString(); password = sdr["password"].ToString(); } } con.Close(); } } if (!string.IsNullOrEmpty(password)) { MailMessage mm = new MailMessage("sender@gmail.com", TextBox1.Text.Trim()); mm.Subject = "Password Recovery"; mm.Body = string.Format("Hi {0},<br /><br />Your password is {1}.<br /><br />Thank You.", username, password); mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(); NetworkCred.UserName = "sender@gmail.com"; NetworkCred.Password = "<password>"; smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Password has been sent to your email address."; } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "This email address does not match our records."; }
منم همین مشکل رو دارم
چجوری میشه حلش کرد؟
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)