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
C#
protected void btnSubmit_Click(object sender, EventArgs e)
    {
     string strcon = ConfigurationManager.ConnectionStrings["prakashConnectionString2"].ConnectionString;
                con = new SqlConnection(strcon);
                con.Open();
                SqlCommand cmd = new SqlCommand("SELECT username,password FROM getezee Where mail= '" + txtEmail.Text.Trim() + "'", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                con.Close();

                if (ds.Tables[0].Rows.Count > 0)
                {
                    MailMessage Msg = new MailMessage();
                    Msg.From = new MailAddress("prakashzon@gmail.com");
                    Msg.To.Add(txtEmail.Text);
                    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("smtp.gmail.com", 587);
                    smtp.Credentials = new System.Net.NetworkCredential("getezee.social@gmail.com", "Risingstar");
                    smtp.EnableSsl = true;
                    smtp.Send(Msg);
                    lbltxt.Text = "Your Password Details Sent to your mail";
                    txtEmail.Text = "";
                }
                else
                {
                    lbltxt.Text = "The Email you entered not exists.";
                }

asp.code

XML
<div>
<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>
</table>
</div>
Posted
Updated 5-Dec-14 0:18am
v4
Comments
Thanks7872 5-Dec-14 6:13am    
https://www.google.co.in/search?q=The+SMTP+server+requires+a+secure+connection+or+the+client+was+not+authenticated.+The+server+response+was%3A+5.5.1&oq=The+SMTP+server+requires+a+secure+connection+or+the+client+was+not+authenticated.+The+server+response+was%3A+5.5.1&aqs=chrome..69i57.391j0j7&sourceid=chrome&es_sm=93&ie=UTF-8

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