密码恢复控制的邮件发送问题 [英] Problem with mail sending of Password recovery control

查看:100
本文介绍了密码恢复控制的邮件发送问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!!!

我正在尝试使用密码恢复控制来恢复密码.它在本地主机上正常工作,但是当我部署网站时,出现错误消息

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>



我在我的web.config中使用这些



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>



我还尝试了将其他端口号用于gmail,但也没有用.



I also tried using different port no for gmail but it too didn''t worked.

推荐答案

亲爱的Frnd,

做到这一点只需输入Webconfig

system.net


添加key ="HostName" value ="smtp.gmail.com"
添加key ="Port" value ="587"
添加key ="EmailFrom" value ="error.website@gmail.com"
添加key ="Username" value ="error.website@gmail.com"
添加key ="UserPass" value =密码"

system.net



你应该用c#编写代码

公共静态int ForgotPassword(字符串uname,字符串电子邮件)
{
Mail_Forgotpassword密码=新的Mail_Forgotpassword();
System.Net.Mail.MailMessage obj =新的System.Net.Mail.MailMessage();
int boolReturnValue = 1;
password.strEmail =电子邮件;
password.strUserName = uname;
DataSet ds = new DataSet();
ds = password.GetPassword();
如果(ds.Tables [0] .Rows.Count> 0)
{
字符串FrstName = ds.Tables [0] .Rows [0] [5] .ToString();
FrstName = FrstName.Substring(0,1).ToUpper()+ FrstName.Substring(1).ToLower();
字符串姓氏= ds.Tables [0] .Rows [0] [6] .ToString();
LastName = LastName.Substring(0,1).ToUpper()+ LastName.Substring(1).ToLower();
字符串strName = ds.Tables [0] .Rows [0] [7] .ToString();
字符串strpwd = ds.Tables [0] .Rows [0] [8] .ToString();
SmtpClient serverobj = new SmtpClient();
serverobj.Credentials =新的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 =新的System.Net.Mail.MailMessage();
obj.From =新MailAddress(ConfigurationManager.AppSettings ["Username"],"Agile EMIS-Zanzibar",System.Text.Encoding.UTF8);
obj.To.Add(电子邮件);
obj.Priority = System.Net.Mail.MailPriority.High;
obj.Subject =密码恢复";
obj.Body =亲爱的" + FrstName +" + LastName +," +"\ n" +"\ n" +我们已经处理了您的密码检索请求.您的帐户详细信息如下所述" +"\ n"+" \ n"+"用户名:"+ strName +" \ n"+"密码:"+ strpwd +" \ n"+" \ n"+"请确保其安全"+" \ n"+" \ n"+"如有其他查询/帮助,请发送电子邮件至admin@gmail.com"+" \ n"+" \ n"+" \ n"+"问候"+" \ n"+" www. gmail.com;
serverobj.Send(obj);
boolReturnValue = 1;

}
其他
{
boolReturnValue = 0;
}

return boolReturnValue;

}
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;

}


这篇关于密码恢复控制的邮件发送问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆