مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

fatimajahani

عضویت از 1393/04/11

فرستادن ایمیل بازیابی کلمه عبور در asp.net

  • شنبه 25 اردیبهشت 1395
  • 21:45
تشکر میکنم

با سلام و خسته نباشید

من از کدهای فرستادن ایمیل بازیابی کلمه عبور در 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.";
 

 

پاسخ های این پرسش

تعداد پاسخ ها : 5 پاسخ
کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • یکشنبه 26 اردیبهشت 1395
  • 08:00

اگر اشتباه نکنم شما از Gmail برای ارسال استفاده کردید که گوگل هم IP ارسال کننده رو مسدود میکنه

وارد لینک زیر بشوید و Enable را انتخاب کنید

https://www.google.com/settings/security/lesssecureapps

کاربر سایت

fatimajahani

عضویت از 1393/04/11

  • یکشنبه 26 اردیبهشت 1395
  • 12:32

سلام ،هنوز داره به این قسمت 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.";
 

 

کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • یکشنبه 26 اردیبهشت 1395
  • 12:49

نوع خطا تغییر کرد

لطفا کد را کامل قرار دهید تا بررسی کنیم

کاربر سایت

fatimajahani

عضویت از 1393/04/11

  • یکشنبه 26 اردیبهشت 1395
  • 13:39
 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.";
        }

 

کاربر سایت

مونا

عضویت از 1395/02/20

  • چهارشنبه 5 خرداد 1395
  • 12:42

منم همین مشکل رو دارم

چجوری میشه حلش کرد؟

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)