Exemplo n.º 1
0
        public async Task SendSuspendedAsync(UserDefinition user, string ccEmail = null)
        {
            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User = user,
            };
            string subject = this.__ResStr("suspendedSubject", "Your account for {0}", Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(user.Email, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "Account Suspended.txt"), Parameters : parms);

            if (!string.IsNullOrWhiteSpace(ccEmail))
            {
                sendEmail.AddBcc(ccEmail);
            }
            await sendEmail.SendAsync(true);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }
Exemplo n.º 2
0
        public async Task SendForgottenEmailAsync(UserDefinition user, string ccEmail = null)
        {
            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User     = user,
                LoginUrl = Manager.CurrentSite.MakeUrl(Manager.CurrentSite.LoginUrl),
            };
            string subject = this.__ResStr("forgotSubject", "Forgotten password for {0}", Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(user.Email, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "Forgot Password.txt"), Parameters : parms);

            if (!string.IsNullOrWhiteSpace(ccEmail))
            {
                sendEmail.AddBcc(ccEmail);
            }
            await sendEmail.SendAsync(true);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }
Exemplo n.º 3
0
        public async Task SendFeedbackAsync(string toEmail, string fromEmail, string subject, string message, string name, string ccEmail = null)
        {
            if (string.IsNullOrWhiteSpace(toEmail) && string.IsNullOrWhiteSpace(ccEmail))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(fromEmail))
            {
                fromEmail = this.__ResStr("anonymous", "(Anonymous User)");
            }

            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                FromEmail = fromEmail,
                Subject   = subject,
                Message   = message,
                Name      = name,
                IPAddress = Manager.UserHostAddress,
                DateTime  = Formatting.FormatDateTime(DateTime.UtcNow),
            };

            subject = this.__ResStr("feedbackSubject2", "Feedback \"{0}\" from {1} - {2}", subject, fromEmail, Manager.CurrentSite.SiteDomain);
            if (string.IsNullOrWhiteSpace(toEmail))
            {
                await sendEmail.PrepareEmailMessageAsync(ccEmail, subject, await sendEmail.GetEmailFileAsync(AreaRegistration.CurrentPackage, "Feedback Email.txt"), Parameters : parms);
            }
            else
            {
                await sendEmail.PrepareEmailMessageAsync(toEmail, subject, await sendEmail.GetEmailFileAsync(AreaRegistration.CurrentPackage, "Feedback Email.txt"), Parameters : parms);

                if (!string.IsNullOrWhiteSpace(ccEmail))
                {
                    sendEmail.AddBcc(ccEmail);
                }
            }
            await sendEmail.SendAsync(true);
        }
Exemplo n.º 4
0
        public async Task SendVerificationAsync(UserDefinition user, string ccEmail = null)
        {
            string      retUrl = Manager.ReturnToUrl;
            string      urlOnly;
            QueryHelper qh = QueryHelper.FromUrl(Manager.CurrentSite.LoginUrl, out urlOnly);

            qh.Add("Name", user.UserName, Replace: true);
            qh.Add("V", user.VerificationCode, Replace: true);
            string urlNoOrigin = qh.ToUrl(urlOnly);

            qh.Add("CloseOnLogin", "true", Replace: true);
            qh.Add(Globals.Link_OriginList, Utility.JsonSerialize(new List <Origin> {
                new Origin {
                    Url = retUrl
                }
            }), Replace: true);
            string url = qh.ToUrl(urlOnly);

            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User        = user,
                Url         = Manager.CurrentSite.MakeUrl(url),
                UrlNoOrigin = Manager.CurrentSite.MakeUrl(urlNoOrigin),
                Code        = user.VerificationCode,
            };
            string subject = this.__ResStr("verificationSubject", "Verification required for site {0}", Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(user.Email, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "Account Verification.txt"), Parameters : parms);

            if (!string.IsNullOrWhiteSpace(ccEmail))
            {
                sendEmail.AddBcc(ccEmail);
            }
            await sendEmail.SendAsync(true);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }
Exemplo n.º 5
0
        public async Task SendPasswordResetEmailAsync(UserDefinition user, string ccEmail = null)
        {
            ResetPasswordModule resetMod = (ResetPasswordModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(ResetPasswordModule));

            ModuleAction reset = resetMod.GetAction_ResetPassword(null, user.UserId, user.ResetKey.ToString());

            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User       = user,
                ResetUrl   = reset.GetCompleteUrl(),
                ResetKey   = user.ResetKey.ToString(),
                ValidUntil = Formatting.FormatDateTime(user.ResetValidUntil),
            };
            string subject = this.__ResStr("resetSubject", "Password Reset for {0}", Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(user.Email, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "Password Reset.txt"), Parameters : parms);

            if (!string.IsNullOrWhiteSpace(ccEmail))
            {
                sendEmail.AddBcc(ccEmail);
            }
            await sendEmail.SendAsync(true);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }