用户忘记密码,想用用户的email来找回密码,哪里有发送密码到用户邮箱的代码?
网上找的都发不出去,听说是邮件服务器的问题,哪里有免费的可以发信的邮箱申请 ?

解决方案 »

  1.   

    那就从邮件服务器的问题出发。换一个G-mail的试试。
      

  2.   


    private bool sendMail(string to, string title, string content)
            {
                SmtpClient _smtpClient = new SmtpClient();
                _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
                _smtpClient.Host = fromSmtp; ;//指定SMTP服务器
                
                _smtpClient.Credentials = new System.Net.NetworkCredential(fromUser, fromPwd);//用户名和密码            MailMessage _mailMessage = new MailMessage(from, to);
                _mailMessage.Subject = title;//主题
                _mailMessage.Body = content;//内容
                _mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
                _mailMessage.IsBodyHtml = true;//设置为HTML格式
                _mailMessage.Priority = MailPriority.High;//优先级
                if (!string.IsNullOrEmpty(mailCC))
                {
                    _mailMessage.CC.Add(mailCC);
                }
                try
                {
                    _smtpClient.Send(_mailMessage);
                    
                    return true;
                }
                catch(Exception ex)
                {
                    WriteLog(to + "发送失败,错误信息:" + ex.Message);
                    return false;
                }
            }
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title>个人会员密码找回</title>
    <link href="/style.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
    // 检查 E-mail 是否已被注册
    function CheckEmail()
    {
    var e = document.getElementById("email").value;
    if(e != "")
    {
    if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(e)) 
    {
    alert("请输入格式正确的E-mail 地址!");
    var email = document.getElementById ( "email" );
    email.value = "";
    email.focus ();


    }function checkAll()
    {
    var ee = document.getElementById("username").value;
    if(ee == "")
    {
    alert('登录名称不能为空');
    return false; 
    }var e = document.getElementById("email").value;
    if(e == "")
    {
    alert('Emial不能为空');
    return false; 
    }
    }</script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div> 
    <table width="778" border="0" align="center" cellpadding="5" cellspacing="0" class="table_huang">
    <tr>
    <td colspan="2" class="TD_huang_14_write"> <span style="font-size: 11pt">>> 获取密码</span></td>
    </tr>
    <tr>
    <td width="26"></td>
    <td width="724"><table width="90%" border="0" cellspacing="2" cellpadding="5">
    <tr>
    <td width="23%"><div align="right">用户名:</div></td>
    <td width="77%">
    <asp:TextBox ID="username" runat="server" Width="150px" ></asp:TextBox></td>
    </tr>
    <tr>
    <td><div align="right">注册时填写的Email:</div></td>
    <td>
    <asp:TextBox ID="email" runat="server" Width="200px" ></asp:TextBox></td>
    </tr>
    <tr>
    <td><div align="right">验证码:</div></td>
    <td><table width="100%">
    <tr>
    <td align="left" valign="top" style="width: 64px"><asp:TextBox ID="txt_validcode" runat="server" Height="15px" Width="62px"></asp:TextBox> </td>
    <td align="left" valign="top"><img id="yzm" src="../ValidateCode.aspx" /></td>
    </tr>
    </table></td>
    </tr>
    <tr><td colspan="2" style="text-align: center">
    <asp:Button ID="Button1" runat="server" Text=" 找回密码 " /></td>
    </tr>
    </table> </td>
    </tr>
    </table> 
    </div>
    </form>
    </body>
    </html>
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;public partial class ClientServer_Default2 : System.Web.UI.Page
    {
    string lspass = "";protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    this.Button1.Attributes.Add("onclick", "javascript:return checkAll();");
    }}
    protected void Button1_Click(object sender, EventArgs e)
    {
    HttpCookie myCookie_validcode = Request.Cookies["FWCX_CheckCode"];
    if (myCookie_validcode.Value.ToString() != txt_validcode.Text)
    {
    Response.Write("<script>");
    Response.Write("alert('验证码错误')");
    Response.Write("</script>");
    return;
    }//首先判断该登录名称和email是否存在
    string sql = "select * from t_users where u_username='" + username.Text.Trim() + "' and u_email='" + email.Text.Trim() + "' and u_class='0' and u_valid='1'";
    DataTable dt = new DataTable();
    //dt = new SQLTool().dataTable(sql);if (dt.Rows.Count < 1)
    {
    Response.Write("<script>alert('登录名称或Email地址错误!,请重新填写后再试。');</script>");}
    else
    {
    //首先给现在的数据库t_users附上一个临时密码
    //Response.Write(CreateRandomCode(8));
    lspass = CreateRandomCode(8);
    sql = "update t_users set u_getpwd='" + lspass + "' where u_username='" + username.Text.Trim() + "' and u_email='" + email.Text.Trim() + "' and u_class='0' and u_valid='1'";
    //if (new SQLTool().ExecuteSql(sql) >= 0)
    //{
    sendEmail(email.Text.Trim(), username.Text.Trim());
    Response.Write("<script>alert('临时密码已经发送到您的注册Email中,请在下一页面中修改密码。');window.location.href='getpwdconfirm.aspx';</script>");
    //}
    }
    }
    public void sendEmail(string email, string name)
    {
    try
    {
    jmail.Message jmessage = new jmail.Message();
    jmessage.Charset = "GB2312";
    jmessage.From = "[email protected]";
    // 发信地址 
    jmessage.MailServerUserName = "86085005";
    //smtp认证用户名(注:如为网易用户,不加要@163.com,只要前面部分即可)
    jmessage.MailServerPassWord = "kingseer";
    // smtp论证用户名密码 jmessage.FromName = "108人力银行";
    // 发信人 
    jmessage.ReplyTo = "[email protected]";
    // 回复地址 
    jmessage.C;//邮件内容为html
    jmessage.Subject = "108人力银行临时密码";string strbody = "";
    strbody += new functions().getInfoXX("t_pagetexts", "p_name", "找回密码邮件反馈-个人", "p_value").Replace("$", name).Replace("@%", lspass);
    jmessage.HTMLBody = strbody;
    // 邮件标题 
    jmessage.AddRecipient(email, "", "");
    jmessage.Send("smtp.163.com", false);//发送邮件smtp.163.com
    jmessage.Close();//关闭对象,释放资源
    }
    catch (Exception err)
    {
    Response.Write(err);
    }
    }
    /// <summary>
    /// 功能:产生数字和字符混合的随机字符串
    /// </summary>
    /// <param name="codecount">字符串的个数</param>
    /// <returns></returns>
    private string CreateRandomCode(int codecount)
    {// 数字和字符混合字符串
    string allchar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n";
    //分割成数组
    string[] allchararray = allchar.Split(',');
    string randomcode = "";//随机数实例
    System.Random rand = new System.Random(unchecked((int)DateTime.Now.Ticks));
    for (int i = 0; i < codecount; i++)
    {
    //获取一个随机数
    int t = rand.Next(allchararray.Length);
    //合成随机字符串
    randomcode += allchararray[t];
    }
    return randomcode;
    }}
      

  4.   

    (凨)
    jmail.Message 这个控件我没有,请问哪里有下载?
      

  5.   

    使用Interop.jmail.dll组件
    jmail.Message Jmail = new jmail.Message(); 
    string strPath = System.Web.HttpContext.Current.Server.MapPath("~/a.html"); 
    StreamReader sr = new StreamReader(strPath, System.Text.Encoding.Default); 
    StringBuilder body = new StringBuilder(); 
    body.Append(sr.ReadToEnd()); 
    sr.Close(); 
    string FromEmail = "[email protected]"; 
    string ToEmail = ""; 
    Jmail.Silent = true; 
    Jmail.Logging = true; 
    Jmail.Charset = "GB2312"; 
    Jmail.ContentType = "text/html"; 
    Jmail.AddRecipient(ToEmail, "", ""); 
    Jmail.From = FromEmail; 
    Jmail.MailServerUserName = ""; 
    Jmail.MailServerPassWord = ""; 
    Jmail.Subject = Subject; 
    Jmail.ContentType="text/html"; 
    Jmail.Body = body.ToString().Trim(); 
    Jmail.Send("smtp.a.com", false); 
    Jmail.Close(); http://topic.csdn.net/u/20091030/13/8f8b778f-4b38-4d72-8569-960f4d7848ac.html
      

  6.   

    visual studio 2005中的ASP.NET好像有完整的找回密码模块,可以直接使用。
    我们以前用的时候好像都是直接采用的。
    至于找回密码的发件服务器好像根本不用,那个找回密码模块里面去配置个服务器出来就成,只是需要输入一个发件邮箱就行了