做注册页面的时候想把 邮箱验证的功能加进去,以后方便找回密码的时候也是把密码发到邮箱里去,现在目前的简单思路是在注册页面随机生成一个验证码,然后用自己的邮箱发到注册的邮箱代码,就是种简单的邮件发送,代码如下,首先我想问下这个方法可不可行?,在Google搜了下还有JMAIL组件,貌似也是发送邮件的组件,用这跟我前面那个方法有什么区别?然后貌似有的网站邮箱注册的时候发送的还提供一个连接单击一下就可以实现激活。这个是怎么实现的,不是先把用户账号先存在数据库里给个字段标记未激活然后单击那个连接后更新字段显示激活?最后问个笼统的问题,各种大,中,小的网站服务器邮件发送是怎么实现的?         MailMessage objMailMessage; 
        // 创建邮件消息 
        objMailMessage = new MailMessage(); 
        objMailMessage.From = "";//源邮件地址 
        objMailMessage.To = "";//目的邮件地址, 
        objMailMessage.Subject = "邮件发送标题:你好";//发送邮件的标题 
        objMailMessage.Body = "邮件发送标内容:测试一下是否发送成功!"+CreateRandomCode(8);//发送邮件的内容 
        //接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本 
         //基本权限 
        objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); 
        //用户名 
        objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]"); 
         //密码 
        objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "fan123456"); 
        //SMTP地址 
         SmtpMail.SmtpServer = "smtp.sina.com.cn"; 
         //开始发送邮件 
        SmtpMail.Send( objMailMessage ); 

解决方案 »

  1.   

    一般使用jmail发送,有个好的例子,你可以参考下:
    public void sendEmail(string sender, string senderuser, string euser, string epwd, string receiver, string subject, string body, string eserver)
        {
            jmail.MessageClass jmMessage = new jmail.MessageClass();
            jmMessage.Charset = "GB2312";
            jmMessage.ISOEncodeHeaders = false;
            jmMessage.From = sender;
            jmMessage.FromName = senderuser;
            jmMessage.Subject = subject;
            jmMessage.MailServerUserName = euser;
            jmMessage.MailServerPassWord = epwd;
            jmMessage.AddRecipient(receiver, "", "");
            
            jmMessage.Body = body;
            if (jmMessage.Send(eserver, false))
            {
                Response.Write("<script language=javascript>alert('发送成功')</script>");
            }
            else
            {
                Response.Write("<script language=javascript>alert('发送失败,请仔细检查邮件服务器的设置是否正确!')</script>");
                jmMessage = null;
                return;
            }
        }
    //发送邮件到注册邮箱
    sendEmail("你的发送邮箱@exun.hk", "你的发送邮箱@exun.hk", "你的发送邮箱@exun.hk", "密码",“要发送的邮箱”, "标题", “内容", "邮箱服务器");
      

  2.   

    安装JMAIL组件没错啊,我asp有做过,可以,不过这asp.net(c#)的东东,1楼回复的这东东我要收藏起来,下次有用哦。哈哈
      

  3.   

    把邮箱和验证码发过去,记下验证码和邮箱,点击激活的时候把注册码和邮箱用url传递或来再用request.querystring("邮箱名")
    request.querystring("验证码")对比记下的邮箱名和验证码是否正确。
      

  4.   

    填写信息后,添加数据到数据库。再发送邮件到用户注册时填写的邮箱。通过pop3,jmail发送。
    大型网站一般有邮件服务器。
    http://www.cnblogs.com/victor_zong/articles/210930.html
    http://www.cnblogs.com/kwklover/archive/2008/09/23/51475.html
      

  5.   

    我上面发的那个例子是可以用的,记得jmail要注册!
      

  6.   

    1楼的方法  刚刚开始发了几封邮件还可以,过后就发不出去了然后我发邮箱就收到这样的一个邮件 如下,貌似是说不能发送邮件,可能是频繁发送邮件的原因吧。有什么办法解决没?Undelivered Mail Returned to SenderThis is the mail system at host smtp3-75.sinamail.sina.com.cn.I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.For further assistance, please send mail to postmaster.If you do so, please include this problem report. You can
    delete your own text from the attached returned message.                   The mail system
      

  7.   

    我是给同一个邮箱发送的,前面了发了5 6封还可以发的到,然后过后发送邮件的那个邮箱就发不出去了还收到这样的邮件,是不是没有办法解决?我想问下用Jmail发邮件跟我上面那种发邮件的方法有什么区别吗?
      

  8.   

    顶下,svnchost.cn那有个用jmail发送邮件的文章,他的网站就是用那做的发送邮件。