发送邮箱密码找回 比如qq邮箱

1.在qq邮箱中设置, 开启pop3协议,自动生成密码   记住密码(下边用)

2. 前台页面

 <tbody>
                      <tr>
                <td width="138" align="right"><span class="f_f15a22">*</span>用户名:</label></td>
                <td width="260"><input runat="server" id="username" name="username" type="text" class="input w205 inputFocus"></td>
                <td><div class="tips" id="loginPwd_tips"></div></td>
              </tr>

            
                  <tr>
                    <td width="138" align="right"><span class="f_f15a22">*</span>邮箱:</td>
                    <td width="260"><input  runat="server" id="email" name="email" type="text" class="w250 input inputFocus grays" placeholder="请输入有效的邮箱"></td>
  </tbody> 


后台代码

    命名空间 
                   using System.Net;
                        using System.Net.Mail;

  
  
protected void Button1_Click ( object sender , EventArgs e )
{
string name = username . Value ; //输入的用户名
string useremail = email . Value ; //输入的邮箱
string selsql = "select * from 表 where realname='" + name + "' and email='" + useremail + "'" ;
DataTable tab = ClassFile . SqlHelper . GetTable ( selsql );
if ( tab . Rows . Count > 0 )
{
string sqlpwd = tab . Rows [ 0 ][ "password" ]. ToString ();
MailMessage mailmessage = new MailMessage (); //创建一个邮件对象
mailmessage . From = new MailAddress ( "开启pop3服务的邮箱比如:**@qq.com" , "用户名 比如:qq昵称" ); //设置发件人账户 用户名
mailmessage . To . Add ( new MailAddress ( useremail )); //设置收件人账号
mailmessage . Subject = "hello 秘密邮件 请勿泄露" ; //设置主题
mailmessage . Body = "呀呀呀 请记住呀----" + sqlpwd ; //设置正文内容 密码
//制定smtp 服务器地址
SmtpClient smtpclient = new SmtpClient ( "smtp.qq.com" ); //smtp.163.com
smtpclient . Credentials = new NetworkCredential ( "开启pop3服务的邮箱比如:**@qq.com" , "邮箱设置开启pop3服务时的密码" ); //设置账户密码 密码是邮箱中设置开启pop3自动生成的密码
smtpclient . EnableSsl = true ; //指定 SmtpClient 使用安全套接字层 (SSL) 加密连接。
smtpclient . Send ( mailmessage ); //发送邮件
}
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值