Ejemplo n.º 1
0
        /// <summary>
        /// 定义邮件内容函数
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Email">EMAIL地址</param>
        /// <param name="pass">相应注册用户的密码(暂时无设置)</param>
        /// <returns></returns>
        public static bool DiscuzSmtpMail(string UserName, string Email, string pass)
        {
            string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower();

            try
            {
                ESM.RecipientName = UserName; //设定收件人姓名
                ESM.AddRecipient(Email);      //设定收件人地址(必须填写)。
                ESM.MailDomainPort = emailinfo.Port;
                ESM.From           = emailinfo.Sysemail;
                ESM.FromName       = configinfo.Webtitle;
                ESM.Html           = true;
                ESM.Subject        = "已成功创建你的 " + configinfo.Forumtitle + "帐户,请查收.";

                StringBuilder body = new StringBuilder();
                body.Append(emailinfo.Emailcontent.Replace("{webtitle}", configinfo.Webtitle));
                body.Replace("{weburl}", string.Format("<a href=\"{0}\">{0}</a>", configinfo.Weburl));
                body.Replace("{forumurl}", string.Format("<a href=\"{0}\">{0}</a>", forumurl));
                body.Replace("{forumtitle}", configinfo.Forumtitle);

                ESM.Body               = "<pre style=\"width:100%;word-wrap:break-word\">" + body.ToString() + "</pre>";
                ESM.MailDomain         = emailinfo.Smtp;
                ESM.MailServerUserName = emailinfo.Username;
                ESM.MailServerPassWord = emailinfo.Password;

                //开始发送
                return(ESM.Send());
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 定义邮件内容函数
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="email">EMAIL地址</param>
        /// <param name="pass">相应注册用户的密码(暂时无设置)</param>
        /// <param name="authstr">相应注册用户的激活链接串参数</param>
        /// <returns></returns>
        public static bool DiscuzSmtpMail(string userName, string email, string pass, string authstr)
        {
            string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower();

            try
            {
                ESM.RecipientName = userName;//设定收件人姓名
                ESM.AddRecipient(email);
                ESM.MailDomainPort = emailinfo.Port;
                ESM.From           = emailinfo.Sysemail;
                ESM.FromName       = configinfo.Webtitle;
                ESM.Html           = true;
                ESM.Subject        = "已成功创建你的 " + configinfo.Forumtitle + "帐户,请查收.";

                StringBuilder body = new StringBuilder();
                body.Append(emailinfo.Emailcontent.Replace("{webtitle}", configinfo.Webtitle));
                body.Replace("{weburl}", string.Format("<a href=\"{0}\">{0}</a>", configinfo.Weburl));
                body.Replace("{forumurl}", string.Format("<a href=\"{0}\">{0}</a>", forumurl));
                body.Replace("{forumtitle}", configinfo.Forumtitle);
                if (authstr == "")
                {
                    ESM.Body = "<pre style=\"width:100%;word-wrap:break-word\">" + body.ToString() + "</pre>";
                }
                else
                {
                    ESM.Body = "<pre style=\"width:100%;word-wrap:break-word\">" + body.ToString() + "\r\n\r\n" + "激活您帐户的链接为:<a href=" + forumurl + "activationuser.aspx?authstr=" + authstr.Trim() + "  target=_blank>" + forumurl + "activationuser.aspx?authstr=" + authstr.Trim() + "</a></pre>";
                }
                ESM.MailDomain         = emailinfo.Smtp;
                ESM.MailServerUserName = emailinfo.Username;
                ESM.MailServerPassWord = emailinfo.Password;

                return(ESM.Send());
            }
            catch
            {
                return(false);
            }
        }