Exemplo n.º 1
0
        //找回密碼
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            DAL.users bll   = new DAL.users();
            var       model = bll.ExistsByUsernameAndEmail(txtusername2.Value.Trim(), txtemail.Value);

            if (model.Rows.Count > 0)
            {
                var              password  = DESEncrypt.Decrypt(model.Rows[0]["password"].ToString());
                BLL.siteconfig   bllConfig = new BLL.siteconfig();
                Model.siteconfig config    = bllConfig.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));

                string body = model.Rows[0]["user_name"] + "您好,請確認您的密碼: " + password + " 請牢記您的密碼";
                // var reWrite = SendMail.Mail(site.emailfrom, site.emailusername, txtemail.Value.Trim(), "會員找回密碼操作", body, site.emailusername, site.emailpassword, site.emailstmp, "");

                var reWrite = DTMail.sendMail(config.emailstmp, config.emailfrom, config.emailpassword, config.emailusername, config.emailfrom, txtemail.Value.Trim(), "會員找回密碼操作", body);
                if (reWrite.Equals("發送失敗"))
                {
                    this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('發送郵件失敗,請重新發送');window.location.href='login.aspx?type=1'</script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('發送郵件成功,請查看郵件');window.location.href='login.aspx'</script>");
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('用戶名或郵箱不存在');window.location.href='login.aspx?type=1'</script>");
            }
        }
Exemplo n.º 2
0
        private void setEmail(string Nom)
        {
            BLL.siteconfig   bll     = new BLL.siteconfig();
            Model.siteconfig model   = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
            string           Content = "你購買的商品訂單已經生成" + "請牢記訂單號:" + Nom + "" + "!";

            DTMail.sendMail(model.emailstmp, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, UserEmail.Value, "帝光房屋", Content);
        }
Exemplo n.º 3
0
 private void setEmail()
 {
     if (IsUserLogin())
     {
         Model.users      modelUser = HttpContext.Current.Session[DTKeys.SESSION_USER_INFO] as Model.users;
         BLL.siteconfig   bll       = new BLL.siteconfig();
         Model.siteconfig model     = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
         DTMail.sendMail(model.emailstmp, model.emailport, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, modelUser.email, "帝光房屋精品物件購買成功通知", "恭喜您購買成功");
     }
 }
Exemplo n.º 4
0
        private void SendEmail(string _LoginName, int _iCt)
        {
            // siteconfig业务逻辑
            ZhouFu.Bll.siteconfig   sitebll = new ZhouFu.Bll.siteconfig();
            ZhouFu.Model.siteconfig site    = sitebll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
            string smtpserver = site.emailstmp;
            string userName   = site.emailusername;
            string pwd        = DESEncrypt.Decrypt(site.emailpassword);
            string nickName   = site.emailnickname;
            string strfrom    = site.emailfrom;
            string strto      = _LoginName;
            string subj       = "邮箱认证";
            string bodys      = HttpContext.Current.Request.Url.Authority + "/RzEmail.aspx?Id=" + Base64Protector.Base64Code(_iCt.ToString());

            DTMail.sendMail(smtpserver, userName, pwd, nickName, strfrom, strto, subj, bodys);
        }
Exemplo n.º 5
0
        private void setEmail(int UserID)
        {
            //生成隨機碼
            string strcode = Utils.GetCheckCode(20);

            //獲得郵件內容
            Model.mail_template mailModel = new BLL.mail_template().GetModel("regverify");
            BLL.siteconfig      bll       = new BLL.siteconfig();
            Model.siteconfig    model     = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
            string titletxt = mailModel.maill_title;
            string bodytxt  = mailModel.content;

            titletxt = titletxt.Replace("{webname}", model.webname);
            titletxt = titletxt.Replace("{username}", DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtusername"));
            bodytxt  = bodytxt.Replace("{webname}", model.webname);
            bodytxt  = bodytxt.Replace("{username}", DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtusername"));
            bodytxt  = bodytxt.Replace("{linkurl}", "<a href=" + "http://" + Utils.GetHomeUrl() + "/RegPay.aspx?uId=" + UserID + ">請點擊連接激活帳戶" + "</a>"); //此處需要修改
            DTMail.sendMail(model.emailstmp, model.emailport, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtemall"), "帝光房屋會員註冊成功通知", bodytxt);
        }
Exemplo n.º 6
0
 private void setEmail(string UserEmail, string Content)
 {
     BLL.siteconfig   bll   = new BLL.siteconfig();
     Model.siteconfig model = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
     DTMail.sendMail(model.emailstmp, model.emailport, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, UserEmail, "帝光房屋留言回覆", Content);
 }
Exemplo n.º 7
0
        private void feedback_add(HttpContext context)
        {
            StringBuilder strTxt = new StringBuilder();

            BLL.plugin_feedback   bll   = new BLL.plugin_feedback();
            Model.plugin_feedback model = new Model.plugin_feedback();

            string _site_path  = DTRequest.GetQueryString("site");
            string _code       = DTRequest.GetFormString("txtCode");
            string _title      = DTRequest.GetFormString("txtTitle");
            string _content    = DTRequest.GetFormString("txtContent");
            string _user_name  = DTRequest.GetFormString("txtUserName");
            string _user_tel   = DTRequest.GetFormString("txtUserTel");
            string _user_qq    = DTRequest.GetFormString("txtUserQQ");
            string _user_email = DTRequest.GetFormString("txtUserEmail");

            //检查站点目录
            if (string.IsNullOrEmpty(_site_path))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}");
                return;
            }
            //校检验证码
            if (string.IsNullOrEmpty(_code))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入验证码!\"}");
                return;
            }
            if (context.Session[DTKeys.SESSION_CODE] == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,验证码已过期!\"}");
                return;
            }
            if (_code.ToLower() != (context.Session[DTKeys.SESSION_CODE].ToString()).ToLower())
            {
                context.Response.Write("{\"status\":0, \"msg\":\"验证码与系统的不一致!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_content))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"对不起,请输入留言的内容!\"}");
                return;
            }
            model.site_path  = Utils.DropHTML(_site_path);
            model.title      = Utils.DropHTML(_title);
            model.content    = Utils.ToHtml(_content);
            model.user_name  = Utils.DropHTML(_user_name);
            model.user_tel   = Utils.DropHTML(_user_tel);
            model.user_qq    = Utils.DropHTML(_user_qq);
            model.user_email = Utils.DropHTML(_user_email);
            model.add_time   = DateTime.Now;
            model.is_lock    = 1; //不需要审核,请改为0

            if (bll.Add(model) > 0)
            {
                //是否开启通知功能
                if (config.bookmsg > 0 && config.receive != "")
                {
                    switch (config.bookmsg)
                    {
                    case 1:
                        DTcms.Model.sms_template smsModel = new DTcms.BLL.sms_template().GetModel(config.booktemplet);     //取得短信内容
                        if (smsModel != null)
                        {
                            //替换模板内容
                            string smstxt = smsModel.content;
                            smstxt = smstxt.Replace("{webname}", siteConfig.webname);
                            smstxt = smstxt.Replace("{webtel}", siteConfig.webtel);
                            smstxt = smstxt.Replace("{weburl}", siteConfig.weburl);
                            smstxt = smstxt.Replace("{username}", model.user_name);
                            smstxt = smstxt.Replace("{usertel}", model.user_tel);
                            smstxt = smstxt.Replace("{userqq}", model.user_qq);
                            smstxt = smstxt.Replace("{useremail}", model.user_email);
                            smstxt = smstxt.Replace("{usertitle}", model.title);
                            smstxt = smstxt.Replace("{usercontent}", model.content);
                            //发送短信
                            string tipMsg = string.Empty;
                            bool   result = new DTcms.BLL.sms_message().Send(config.receive, smstxt, 1, out tipMsg);
                            if (!result)
                            {
                                LogHelper.WriteLog("手机信息发送失败!");
                            }
                        }
                        break;

                    case 2:
                        //获得邮件内容
                        DTcms.Model.mail_template mailModel = new DTcms.BLL.mail_template().GetModel(config.booktemplet);
                        if (mailModel != null)
                        {
                            //替换模板内容
                            string titletxt = mailModel.maill_title;
                            string bodytxt  = mailModel.content;

                            titletxt = titletxt.Replace("{webname}", siteConfig.webname);
                            titletxt = titletxt.Replace("{username}", model.user_name);

                            bodytxt = bodytxt.Replace("{webname}", siteConfig.webname);
                            bodytxt = bodytxt.Replace("{webtel}", siteConfig.webtel);
                            bodytxt = bodytxt.Replace("{weburl}", siteConfig.weburl);

                            bodytxt = bodytxt.Replace("{username}", model.user_name);
                            bodytxt = bodytxt.Replace("{usertel}", model.user_tel);
                            bodytxt = bodytxt.Replace("{userqq}", model.user_qq);
                            bodytxt = bodytxt.Replace("{useremail}", model.user_email);
                            bodytxt = bodytxt.Replace("{usertitle}", model.title);
                            bodytxt = bodytxt.Replace("{usercontent}", model.content);
                            //循环发送
                            string[] emailArr = config.receive.Split(',');
                            foreach (string email in emailArr)
                            {
                                if (DTcms.Common.Utils.IsValidEmail(email))
                                {
                                    //发送邮件
                                    try
                                    {
                                        DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl,
                                                        siteConfig.emailusername,
                                                        DESEncrypt.Decrypt(siteConfig.emailpassword, siteConfig.sysencryptstring),
                                                        siteConfig.emailnickname,
                                                        siteConfig.emailfrom,
                                                        email,
                                                        titletxt, bodytxt);
                                    }
                                    catch
                                    {
                                        LogHelper.WriteLog("邮件发送失败!");
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
                context.Response.Write("{\"status\": 1, \"msg\": \"恭喜您,留言提交成功!\"}");
                return;
            }
            context.Response.Write("{\"status\": 0, \"msg\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
Exemplo n.º 8
0
 private void setEmail()
 {
     BLL.siteconfig   bll   = new BLL.siteconfig();
     Model.siteconfig model = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
     DTMail.sendMail(model.emailstmp, model.emailport, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, "*****@*****.**", "帝光房屋會員刊登土地新物件", "帝光房屋會員刊登土地新物件");
 }
Exemplo n.º 9
0
 private void setEmail()
 {
     BLL.siteconfig   bll   = new BLL.siteconfig();
     Model.siteconfig model = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
     DTMail.sendMail(model.emailstmp, model.emailport, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtemall"), "帝光房屋會員註冊成功通知", "恭喜您成功註冊我們的會員");
 }
Exemplo n.º 10
0
        private void SendVerifyEmail(int userId, string email, Action <int, string> callback, string templateName = "emailverify")
        {
            if (userId <= 0 || string.IsNullOrWhiteSpace(email))
            {
                callback((int)HttpStatusCode.BadRequest, "缺少参数");
                return;
            }
            // verifying_email : string | last_send_verifying_mail_at : DateTime? | verifying_email_code : string
            // 限制发送的时间间隔
            var lastSendVerifyingMailAt = (DateTime?)SessionHelper.Get("last_send_verifying_mail_at");

            if (lastSendVerifyingMailAt != null && DateTime.Now.Subtract(lastSendVerifyingMailAt.Value).TotalSeconds < 60)
            {
                callback(429, "发送邮件间隔为 60 秒,您刚才已经发送过啦,休息一下再来吧!");
                return;
            }
            var context = new Agp2pDataContext();
            // 检查是否有其他用户验证过此邮箱
            var count = context.dt_users.Count(u => u.email == email);

            if (count != 0)
            {
                callback((int)HttpStatusCode.Conflict, "这个电子邮箱已经被其他用户绑定了");
                return;
            }

            var strCode = Utils.GetCheckCode(5);

            SessionHelper.Set("verifying_email", email);
            SessionHelper.Set("last_send_verifying_mail_at", DateTime.Now);
            SessionHelper.Set("verifying_email_code", strCode);

            var user = context.dt_users.Single(u => u.id == userId);

            //获得邮件内容
            var mailModel = new mail_template().GetModel(templateName);

            if (mailModel == null)
            {
                callback((int)HttpStatusCode.Gone, "邮件发送失败,邮件模板内容不存在!");
                return;
            }
            //替换模板内容
            var siteConfig = new siteconfig().loadConfig();
            var titletxt   = mailModel.maill_title
                             .Replace("{webname}", siteConfig.webname)
                             .Replace("{username}", user.user_name);
            var bodytxt = mailModel.content
                          .Replace("{webname}", siteConfig.webname)
                          .Replace("{webtel}", siteConfig.webtel)
                          .Replace("{username}", user.user_name)
                          .Replace("{valid}", SessionHelper.GetSessionTimeout().ToString())
                          .Replace("{linkurl}",
                                   "http://" + HttpContext.Current.Request.Url.Authority.ToLower() +
                                   "/user/center/index.html#/safe?action=verifyEmail&code=" + strCode)
                          .Replace("{verifyCode}", strCode);

            try
            {
                DTMail.sendMail(siteConfig.emailsmtp,
                                siteConfig.emailusername,
                                DESEncrypt.Decrypt(siteConfig.emailpassword),
                                siteConfig.emailnickname,
                                siteConfig.emailfrom,
                                email,
                                titletxt, bodytxt); //发送邮件
                callback((int)HttpStatusCode.OK, "邮件发送成功,请查收!");
            }
            catch (Exception e)
            {
                callback((int)HttpStatusCode.InternalServerError, "邮件发送失败,请联系本站管理员!");
            }
        }
Exemplo n.º 11
0
        //提交发送
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("user_sms", DTEnums.ActionEnum.Add.ToString()); //检查权限

            string emailList  = txtEmailList.Text.Trim();
            string emailTitle = txtTitle.Text.Trim();
            string emailBody  = txtContent.Value;

            if (emailTitle.Length == 0)
            {
                JscriptMsg("请输入邮件标题!", "");
                return;
            }
            if (emailBody.Length == 0)
            {
                JscriptMsg("请输入邮件内容!", "");
                return;
            }
            //邮箱地址
            List <string> list = null;

            //检查发送类型
            if (rblSmsType.SelectedValue == "1")
            {
                list = new List <string>();
                if (emailList.Length == 0)
                {
                    JscriptMsg("请输入邮箱地址!", "");
                    return;
                }
                string[] emailArr = emailList.Split(',');
                foreach (string _email in emailArr)
                {
                    list.Add(_email);
                }
            }
            else
            {
                ArrayList al = new ArrayList();
                for (int i = 0; i < cblGroupId.Items.Count; i++)
                {
                    if (cblGroupId.Items[i].Selected)
                    {
                        al.Add(cblGroupId.Items[i].Value);
                    }
                }
                if (al.Count < 1)
                {
                    JscriptMsg("请选择会员组别!", "");
                    return;
                }
                list = GetGroupEmail(al);
            }

            int sucCount   = 0; //成功数量
            int errorCount = 0; //失败数量

            foreach (string _email in list)
            {
                if (Utils.IsValidEmail(_email))
                {
                    try
                    {
                        DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl,
                                        siteConfig.emailusername,
                                        DESEncrypt.Decrypt(siteConfig.emailpassword, siteConfig.sysencryptstring),
                                        siteConfig.emailnickname,
                                        siteConfig.emailfrom,
                                        _email,
                                        emailTitle,
                                        emailBody);
                        sucCount++;
                    }
                    catch
                    {
                        errorCount++;
                    }
                }
                else
                {
                    errorCount++;
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "成功发送邮件" + sucCount + "条,失败" + errorCount + "条!"); //记录日志
            JscriptMsg("成功发送邮件" + sucCount + "条,失败" + errorCount + "条!", "user_email.aspx");
        }
Exemplo n.º 12
0
 private void setEmail()
 {
     BLL.siteconfig   bll   = new BLL.siteconfig();
     Model.siteconfig model = bll.loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_SITE_XML_CONFING));
     DTMail.sendMail(model.emailstmp, model.emailfrom, model.emailpassword, model.emailusername, model.emailfrom, lblEmail.Text, "帝光房屋留言回覆", txtReContent.Text);
 }