Click here to Skip to main content
15,936,119 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I got error: 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 ...

C# code
protected void btnSubmit_Click(object sender, EventArgs e)
     string strcon = ConfigurationManager.ConnectionStrings["prakashConnectionString2"].ConnectionString;
                con = new SqlConnection(strcon);
                SqlCommand cmd = new SqlCommand("SELECT username,password FROM getezee Where mail= '" + txtEmail.Text.Trim() + "'", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();

                if (ds.Tables[0].Rows.Count > 0)
                    MailMessage Msg = new MailMessage();
                    Msg.From = new MailAddress("");
                    Msg.Subject = "Your Password Details";
                    Msg.Body = "Hi, <br />Please check your Login Detailss<br /><br />Your Username: " + ds.Tables[0].Rows[0]["username"] + "<br /><br />Your Password: " + ds.Tables[0].Rows[0]["password"] + "<br /><br />";
                    Msg.IsBodyHtml = true;
                    SmtpClient smtp = new SmtpClient("", 587);
                    smtp.Credentials = new System.Net.NetworkCredential("", "Risingstar");
                    smtp.EnableSsl = true;
                    lbltxt.Text = "Your Password Details Sent to your mail";
                    txtEmail.Text = "";
                    lbltxt.Text = "The Email you entered not exists.";


<table cellspacing="2" cellpadding="2" border="0" class="auto-style18">
<tr><td class="auto-style20"></td><td class="auto-style20"><b>Forgot Password</b></td></tr>
<tr><td><b>Enter Your Email:</b></td><td><asp:TextBox ID="txtEmail" runat="server" /></td></tr>
<tr><td class="auto-style19"></td><td class="auto-style19"><asp:button ID="btnSubmit" Text="Submit"  runat="server" CssClass="Button" OnClick="btnSubmit_Click"/></td></tr>
<tr><td colspan="2" style=" color:red"><asp:Label ID="lbltxt" runat="server"/></td></tr>
Updated 5-Dec-14 0:18am
Thanks7872 5-Dec-14 6:13am

Did you try any of this solutions?
Member 10918596 5-Dec-14 6:15am    
what is this?
Ankur\m/ 5-Dec-14 6:16am    
To me it seems like a Google search result for your error message.
Richard Deeming 5-Dec-14 8:02am    
Your code is vulnerable to SQL Injection[^].

NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Also, you're storing your passwords in plain text. Don't do that; you should only ever store a salted hash of the password.
Salted Password Hashing - Doing it Right[^]

1 solution

To change setting in gmail accounts directly for secure Low
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900