Click here to Skip to main content
15,915,702 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all!!!

I am trying to recover my password using password recovery control. It's working on local host but when i deployed my website it gives me error that

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. tw10sm3434281obb.20



    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" BackColor="#E3EAEB"
        BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px"
        Font-Names="Verdana" Font-Size="0.8em" Height="221px" Width="446px">
        <SubmitButtonStyle BackColor="White" BorderColor="#C5BBAF" BorderStyle="Solid"
            BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#1C5E55" />
        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
        <MailDefinition From="error.website@gmail.com"
            Subject="Your Password For the Monal Handicraft Website">
        </MailDefinition>
        <SuccessTextStyle Font-Bold="True" ForeColor="#1C5E55" />
        <TextBoxStyle Font-Size="0.8em" />
        <TitleTextStyle BackColor="#1C5E55" Font-Bold="True" Font-Size="0.9em"
            ForeColor="White" />
</asp:PasswordRecovery>


I am using these in my web.config
<system.net>

    
      <mailSettings>
        <smtp>
          <network
            host="smtp.gmail.com"
            userName="error.website@gmail.com"
            password="password" port="587" />

        </smtp>
      </mailSettings>
    
  </system.net>


I also tried using different port no for gmail but it too didn't worked.
Posted
Updated 4-May-12 1:00am
v2

1 solution

Dear Frnd,

Do like this Just give in Webconfig

system.net


add key="HostName" value="smtp.gmail.com"
add key="Port" value="587"
add key="EmailFrom" value="error.website@gmail.com"
add key="Username" value="error.website@gmail.com"
add key="UserPass" value="password"

system.net



And u should written the Code in c#

public static int ForgotPassword(string uname, string email)
{
Mail_Forgotpassword password = new Mail_Forgotpassword();
System.Net.Mail.MailMessage obj = new System.Net.Mail.MailMessage();
int boolReturnValue = 1;
password.strEmail = email;
password.strUserName = uname;
DataSet ds = new DataSet();
ds = password.GetPassword();
if (ds.Tables[0].Rows.Count > 0)
{
string FrstName = ds.Tables[0].Rows[0][5].ToString();
FrstName = FrstName.Substring(0, 1).ToUpper() + FrstName.Substring(1).ToLower();
string LastName = ds.Tables[0].Rows[0][6].ToString();
LastName = LastName.Substring(0, 1).ToUpper() + LastName.Substring(1).ToLower();
string strName = ds.Tables[0].Rows[0][7].ToString();
string strpwd = ds.Tables[0].Rows[0][8].ToString();
SmtpClient serverobj = new SmtpClient();
serverobj.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["Username"].ToString(), ConfigurationManager.AppSettings["UserPass"].ToString());
serverobj.Port = System.Convert.ToInt32(ConfigurationManager.AppSettings["Port"].ToString());
serverobj.Host = ConfigurationManager.AppSettings["HostName"].ToString(); ;
serverobj.EnableSsl = false;
obj = new System.Net.Mail.MailMessage();
obj.From = new MailAddress(ConfigurationManager.AppSettings["Username"], "Agile EMIS - Zanzibar", System.Text.Encoding.UTF8);
obj.To.Add(email);
obj.Priority = System.Net.Mail.MailPriority.High;
obj.Subject = "Password Recovery";
obj.Body = "Dear " + FrstName + " " + LastName + "," + "\n" + "\n" + "We have processed your request for password retrieval. Your account details are as mentioned below" + "\n" + "\n" + "UserName :" + strName + "\n" + "Password :" + strpwd + "\n" + "\n" + "Please keep them safe" + "\n" + "\n" + "For any further queries/assistance kindly mail us at admin@gmail.com" + "\n" + "\n" + "\n" + "Regards," + "\n" + "www.gmail.com";
serverobj.Send(obj);
boolReturnValue = 1;

}
else
{
boolReturnValue = 0;
}

return boolReturnValue;

}
 
Share this answer
 
v3
Comments
ujjwal uniyal 4-May-12 7:22am    
Ok i will do this but where should i call this function ?? And how will i pass username and email to this function?? Using profileCommon ??
Anil Honey 206 4-May-12 7:43am    
Seen in this Code first ths Username and MailID Should match based on that we wil retrieve the related Password frst u pass the usernamse and mail id to this Function.Ur Using stored Procedures and 3 tier architecture right.

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