Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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>




c# code
C#
SqlConnection con = new SqlConnection("Data Source=***_06;Initial Catalog=****;User ID=***;Password=****");            
                con.Open();
                SqlCommand cmd = new SqlCommand("select username,password from getezee Where mail=@mails",con);
                cmd.Parameters.AddWithValue("@mails", txtEmail.Text.Trim());
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                ds = new DataSet();
                da.Fill(ds);
                con.Close();
            
            if (ds.Tables[0].Rows.Count > 0)
            {
                MailMessage Msg = new MailMessage();   // Sender e-mail address.               
                Msg.From = new MailAddress("prakash@gmail.com");   // Recipient e-mail address.             
                Msg.To.Add(txtEmail.Text.ToString());
                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.Host = "smtp.gmail.com";
                smtp.Port = 587;             
                smtp.Credentials = new NetworkCredential("prakash@gmail.com", "prakash");
                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.";
            }
Posted
Updated 4-Dec-14 20:21pm
v3
Comments
Praveen Kumar Upadhyay 5-Dec-14 2:25am    
Is it a question??
Member 10918596 5-Dec-14 2:27am    
Forgot Password By Email Page Code In Asp.Net
Member 10918596 5-Dec-14 2:26am    
when i run 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

Try setting UseDefaultCredentials=false

smtp.UseDefaultCredentials = false;
 
Share this answer
 
Comments
Member 10918596 5-Dec-14 2:35am    
i got same error...
Praveen Kumar Upadhyay 5-Dec-14 2:38am    
Try using port 25.
Praveen Kumar Upadhyay 5-Dec-14 3:00am    
As per my knowledge this is basically your firewall blocking the request to send. Please check with your network team.
Member 10918596 5-Dec-14 3:00am    
not working
Remove this line,
smtp.EnableSsl = true;

Okay, try this:

C#
string name ="name";
                    string password = "password";
                    string email_id = "email";

                    MailMessage mail = new MailMessage();
                    mail.From = new MailAddress("blah@gmail.com");
                    mail.To.Add(email);

                    mail.Subject = "Password Recovery ";
                    mail.Body = "Name : " + name +
                                "<br />Password : " + password +
                                "<br />Email : " + email_id;
                    mail.IsBodyHtml = true;

                    SmtpClient client = new SmtpClient();
                    client.Host = "smtp.gmail.com";
                    client.Port = 587;
                    client.EnableSsl = true;
                    client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                    client.Credentials = new System.Net.NetworkCredential("blah@gmail.com", "8888888888");
                    client.Timeout = 2000000;
                    client.Send(mail);


-KR
 
Share this answer
 
v2
Comments
Praveen Kumar Upadhyay 5-Dec-14 2:59am    
smtp.EnableSsl = true have to be there, otherwise it will give below error.

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command
Member 10918596 5-Dec-14 3:02am    
when i remove this line i got new error The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. w5sm19667503pdj.13 - gsmtp
Krunal Rohit 5-Dec-14 3:07am    
See the updated answer.


-KR
Krunal Rohit 5-Dec-14 3:02am    
Let the OP try the solution first.

-KR

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



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