C # MVC blog development (3) registration

In doing registration when bloggers met a very pit father's problem
is that local send mail normal but carried to Ali cloud server to send mail to gg query for a long time before we know Ali cloud defaults to 25 send an email port to the closure

is It is said that the mail sent on the Alibaba Cloud server cannot be sent without ssl encryption. We must send the mail through the 465 port of the ssl home.
Then we call the packaged Mail class
Mail class download address: download address The
format of the sent mail is as follows:

 

 

 

  string title = "博客账号激活";
  string MailContent = "您好,感谢您在我的博客注册帐户!激活帐户需要点击下面的链接:" + xxxx + "";
  Boolean r = Mail.WebSendEmail("发送给的邮箱号", "", title, MailContent);

 

Of course, I did n’t post some fields that were needed in the registration link. The fields were generated during registration and inserted into the database. When he visited, he went to the database to determine whether the field values ​​were the same and the time expired. Give the account activation, the general idea is that I will not post the actual code.
Of course, I also need to pay attention to the problem when sending emails using tx mailboxes. That is, the password for sending emails before tx is an independent password. Now the authorization code is changed to the authorization code . After starting stmp,

all the registration codes are as follows (some data links are not convenient to show and delete):

 

 

  #region 注册
        //注册
        [ErrorHandler]
        public ActionResult Register(Entity.Member memeber, string vercode, string rePassword)
        {
            Entity.Alert alert = new Entity.Alert();
            if (IsPost)
            {
                string validateCode = Session["ValidateCode"].ToString();
                if (memeber.Password.Length<6||memeber.Password.Length>16)
                {
                    alert.status = 1;
                    alert.msg = "密码长度应该为6-16位";
                    return Json(alert, JsonRequestBehavior.AllowGet);

                }
                
                if (memeber.Password != rePassword)
                {
                    alert.status = 1;
                    alert.msg = "两次密码不一致";
                    return Json(alert, JsonRequestBehavior.AllowGet);

                }
                else
                {
                    if (vercode != validateCode)
                    {
                        alert.status = 1;
                        alert.msg = "人类验证失败";
                        return Json(alert, JsonRequestBehavior.AllowGet);

                    }
                    else
                    {
                        Entity.Member getEmail = Entity.Helper.Member.GetMemberByEmail(memeber.Email);
                        if (getEmail != null)
                        {
                            alert.status = 1;
                            alert.msg = "该邮箱已经注册";
                            return Json(alert, JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            string Code = Entity.Helper.Common.GenerateCheckCode(12);
                            memeber.Password = memeber.Password.Encrypt();
                            memeber.Power = "1";
                            memeber.State = "0";
                            memeber.Sex = "0";
                            memeber.Img = "/attached/2017/11/231552029959.jpg";
                            memeber.Describe = "这个人很懒还未设置签名";
                            memeber.ZcTime = DateTime.Now;
                            memeber.Code = Code;
                            Entity.Helper.Member.Register(memeber);
                            try
                            {
                                Entity.Member ActiveMail = Entity.Helper.Member.GetMemberByEmail(memeber.Email);
                                xsw.Framework.Config.FrameworkConfig config =
                                xsw.Framework.Config.FrameworkConfig.Instance<xsw.Framework.Config.FrameworkConfig>();
                             
                                string title = "博客账号激活";
                                string MailContent = "您好,感谢您在我的博客注册帐户!激活帐户需要点击下面的链接:";
                              
                                Boolean r = Mail.WebSendEmail(memeber.Email, "", title, MailContent);
                              

                                Entity.SiteMessages message = new SiteMessages();
                                message.Content = "欢迎注册博客;
                                message.SendUserID="1";
                                message.UserID=ActiveMail.MemberID.ToString();
                                message.IsView=false;
                                message.Title="欢迎";
                                message.CreateDate=DateTime.Now;
                                DBSession.TryGet().Insert<SiteMessages>(message);

                            }
                            catch (Exception e)
                            {
                            
                                alert.status = 1;
                                alert.msg = "注册成功,但激活邮件发送失败";
                            }
                            alert.action = "Login";
                            alert.status = 0;
                            alert.msg = "注册成功";
                            return Json(alert, JsonRequestBehavior.AllowGet);
                        }
                    }

                }

            }


            return ManageView();
        }


 

Published 29 original articles · Like 11 · Visits 10,000+

Guess you like

Origin blog.csdn.net/u010840685/article/details/79305003