Esempio n. 1
0
        public void Consume(ResetPasswordRequestMessage resetPasswordRequestMessage)
        {
            var subject = _translationService.Translate("RequestToResetYourPassword", resetPasswordRequestMessage.CultureInfo);

            dynamic viewBag = new DynamicViewBag();

            viewBag.Culture = resetPasswordRequestMessage.CultureInfo;

            var mailMessage = CreateRazorMailMessage
                              (
                "ResetPassword.ResetPasswordMailMessage.cshtml",
                new
            {
                resetPasswordRequestMessage.DisplayName,
                resetPasswordRequestMessage.ResetPasswordUrl,
                Subject = subject
            },
                viewBag
                              );

            mailMessage.From = new MailAddress("*****@*****.**");
            mailMessage.To.Add(resetPasswordRequestMessage.Email);
            mailMessage.Subject = subject;

            _mailer.SendMail(mailMessage);
        }
Esempio n. 2
0
        public ActionResult Register(RegisterViewModel registerViewModel)
        {
            if (ModelState.IsValid)
            {
                string userName      = registerViewModel.userName;
                string password      = registerViewModel.password;
                string emailId       = registerViewModel.email;
                string displayName   = registerViewModel.displayName;
                var    statusMessage = Messages.ErrorSendingEmail;
                var    hostName      = Resources.GetHostName(HttpContext.Request.Url.ToString());
                string mailContent   = mailer.MailContentBuilder(Messages.RegistrationMessageBody, new string[] { displayName, hostName, Url.Action("RegisterEmailVerfication", "Account", new { verfid = registerViewModel.emailVerifiationId }) });
                mailer.SetMailData(emailId, Messages.RegistrationSubject, mailContent, true, true);
                if (mailer.SendMail())
                {
                    using (userRepository)
                    {
                        if (!userRepository.AddUser(userName, password, emailId, displayName))
                        {
                            ModelState.AddModelError("", Messages.RegistrationError);
                            return(View("Register", registerViewModel));
                        }

                        statusMessage = Messages.RegistrationSuccess;
                    }

                    TempData["statusMessage"] = statusMessage;
                    return(RedirectToAction("Messager"));
                }

                TempData["statusMessage"] = statusMessage;
                return(RedirectToAction("Messager"));
            }

            return(View("Register", registerViewModel));
        }
Esempio n. 3
0
        public IHttpActionResult SendPrayerRequest(PrayerRequest prayerRequest)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Values
                             .SelectMany(v => v.Errors)
                             .Select(m => m.ErrorMessage);

                return(Ok(new PrayerRequestResponse
                {
                    Success = false,
                    Text = "Sorry your email was not sent because: " + string.Join(", ", errors)
                }));
            }

            try
            {
                // Get email content
                var text = _mailer.ReadTextFromFile(_props.PrayerResponseEmailFilePathText);
                var html = _mailer.ReadTextFromFile(_props.PrayerResponseEmailFilePathHtml);

                // Send prayer request email
                _mailer.SendMail(_props.SmtpClientHost, _props.SmtpClientPort, _props.SmtpUserName, _props.SmtpPassword,
                                 fromEmail: prayerRequest.Email,
                                 toEmail: _props.PrayerRequestEmailAddress,
                                 subject: _props.PrayerRequestEmailSubject,
                                 text: /*System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(*/ prayerRequest.PrayFor /*, true)*/); // It's text - it doesn't need anti xss

                // Send prayer response email
                _mailer.SendMail(_props.SmtpClientHost, _props.SmtpClientPort, _props.SmtpUserName, _props.SmtpPassword,
                                 fromEmail: _props.PrayerRequestEmailAddress,
                                 toEmail: prayerRequest.Email,
                                 subject: _props.PrayerResponseEmailSubject,
                                 text: text,
                                 html: html);
            }
            catch (Exception ex)
            {
                Trace.TraceError("{0}\r\n\r\nStack Trace:\r\n\r\n{1}", ex.Message, ex.StackTrace);

                return(Ok(new PrayerRequestResponse
                {
                    Success = false,
                    Text = "Your prayer request has not been sent - please try mailing: " + _props.PrayerRequestEmailAddress
                }));
            }

            Trace.TraceInformation("Prayer request sent.");
            return(Ok(new PrayerRequestResponse
            {
                Success = true,
                Text = "Thanks for sending your prayer request - we will pray."
            }));
        }
Esempio n. 4
0
        public JsonResult InviteAFriend(string userId)
        {
            DataSet userDetailSet    = iFriendInvitationRepository.GetUserDetails(userId);
            bool    invitationStatus = false;

            if (userDetailSet.Tables.Count > 0)
            {
                UserDetailsViewModel userDetailsViewModel = userDetailSet.Tables[0].AsEnumerable().Select(result => new UserDetailsViewModel
                {
                    UserId      = result.Field <string>("UserId"),
                    UserName    = result.Field <string>("UserName"),
                    EmailId     = result.Field <string>("EmailId"),
                    CompanyId   = result.Field <int>("CompanyId"),
                    CompanyName = result.Field <string>("CompanyName")
                }).FirstOrDefault();
                var    hostName    = Resources.GetHostName(HttpContext.Request.Url.ToString());
                string mailContent = mailer.MailContentBuilder(Messages.InviteFriendToCompanyEmailBody,
                                                               new string[] { userDetailsViewModel.UserName,
                                                                              hostName, Url.Action("AcceptInvitation", "InviteFriends",
                                                                                                   new { area = "InviteFriends", userName = userDetailsViewModel.UserId, verfid = encDecryption.Encrypt(Convert.ToString(userSession.CompanyId)) }),
                                                                              User.Identity.Name });
                mailer.SetMailData(userDetailsViewModel.EmailId, string.Format("Invitation from {0}", User.Identity.Name), mailContent, true, true);
                invitationStatus = mailer.SendMail() ? iFriendInvitationRepository.LogInvitation(userId, SessionUserId, userDetailsViewModel.CompanyId.GetDefaultValueIfNull <string>()) : false;
            }

            return(Json(invitationStatus, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public void SendNewPasswordbyEmail(string userName, IMailer mailer)
        {
            IUserNew user = _provider.GetUserByUserName(userName);

            if (user == null)
            {
                return;
            }


            if (user.UserName.ToLower() == "fenealuil")
            {
                return;
            }

            string pwd = Guid.NewGuid().ToString();

            user.Password = pwd.Substring(0, 8);

            user.PasswordData = DateTime.Now.Date;

            _provider.UpdateUserPassword(user);

            try
            {
                if (mailer != null)
                {
                    mailer.SendMail(user.Mail, "Invio nuova password", "La password è: " + user.Password);
                }
            }
            catch (Exception)
            {
                //non fa niente
            }
        }
        public IActionResult Contact(EmailFormModel model)
        {
            if (ModelState.IsValid)
            {
                _mailer.SendMail(model.Name, model.Email, model.Message);
                ModelState.Clear();
                ViewBag.Notify = "Your Message was sent successfully. Someone will contact you soon.";
            }

            return(View());
        }
Esempio n. 7
0
            public async Task <string> Handle(Command command, CancellationToken cancellationToken)
            {
                Entry entry = new Entry
                {
                    Tags = command.Tags.ToList()
                };

                await _session.StoreAsync(entry, cancellationToken);

                await _session.SaveChangesAsync(cancellationToken);

                _mailer.SendMail("*****@*****.**", "New entry created", String.Join(", ", entry.Tags));

                return(entry.Id);
            }
Esempio n. 8
0
            protected override async Task Handle(Command command, CancellationToken cancellationToken)
            {
                User user = new User();

                user.Email  = command.Email;
                user.Claims = new List <(string, string)>
                {
                    (AppClaims.CreateNewEntry, "")
                };

                using var session = _store.OpenAsyncSession();
                await session.StoreAsync(user, cancellationToken);

                await session.SaveChangesAsync(cancellationToken);

                _mailer.SendMail("*****@*****.**", "New user created", "Email body...");
            }
Esempio n. 9
0
        public static void DoWork(List<User> users, IMailer mailer)
        {
            var secrets = new List<User>();
            secrets.AddRange(users);

            //shuffle secrets:
            secrets = secrets.Shuffle(new Random(DateTime.Now.Millisecond)).ToList();

            //shuffle not perfect: check for mistakes
            while (GetError(secrets, users))
            {
                secrets = secrets.Shuffle(new Random(DateTime.Now.Millisecond)).ToList();
            }

            for (int i = 0; i < users.Count; i++)
            {
                var user = users[i];
                //Debug.WriteLine(string.Format("{0} to {1}", user.Email, secrets[i].Name));
                mailer.SendMail(user.Name, user.Email, secrets[i].Name, secrets[i].Wishes);
            }
        }
Esempio n. 10
0
        public Signal PushSignalToSubscribers(int signalId)
        {
            Signal pushedEntity = null;

            IMetaSettingRepository settingsRepository = _DataRepositoryFactory.GetDataRepository <IMetaSettingRepository>();
            string type = Constants.MetaSettings.Types.Communication;
            string code = Constants.MetaSettings.Codes.EmailSender;
            string name = settingsRepository.GetSetting(type, code).Value;

            using (IMailer mailer = _MailerFactory.GetMailer(name))
                using (IDbContextRepository <Signal> signalRepository = _DataRepositoryFactory.GetDataRepository <ISignalRepository>())
                {
                    Signal signal = signalRepository.EntitySet.FirstOrDefault(s => s.SignalID == signalId);

                    List <Subscription> subscriptions = signal.Product.Subscriptions;

                    // send signal to subscribers
                    foreach (var subscription in subscriptions)
                    {
                        string   sender     = "*****@*****.**";
                        string   recipients = subscription.Account.LoginEmail;
                        string   subject    = string.Format("Alert - New MarketMiner Signal - {0} - {1}", signal.Instrument, signal.Granularity);
                        string   side       = signal.Side == "S" ? "SELL" : signal.Side == "B" ? "BUY" : "NONE";
                        DateTime time       = Convert.ToDateTime(signal.SignalTime).ToUniversalTime();
                        string   body       = string.Format("New Signal - {0} : {1} : {2} : {3} : {4} : {5}", signal.Type, side, signal.Instrument, signal.Granularity, signal.SignalPrice, time);

                        mailer.SendMail(sender, recipients, subject, body);
                    }

                    // postmark the signal
                    signal.SendPostmark = DateTime.UtcNow;

                    signalRepository.Context.SaveChanges();

                    pushedEntity = signalRepository.Entity(signal);
                }

            return(pushedEntity);
        }
Esempio n. 11
0
        public void SendErrorEmail(ErrorReportInfo errorInfo)
        {
            try
            {
                var subject = string.Format("{0} Error", Assembly.GetExecutingAssembly().GetName().Name);

                if (null != errorInfo.Server && null != errorInfo.Location &&
                    !string.IsNullOrWhiteSpace(errorInfo.Location.ControllerAction) &&
                    !string.IsNullOrWhiteSpace(errorInfo.Server.HostName))
                {
                    subject = string.Format("{0}: {1} - {2}", subject, errorInfo.Server.HostName,
                                            errorInfo.Location.ControllerAction);
                }

                var to = AppSettings.Default.Email.ErrorMessageTo;
                _mailer.SendMail(to, subject, errorInfo.ReportHtml);

                _log.Info("Sent email: {0} to {1}", subject, to);
            }
            catch (Exception ex)
            {
                _log.Error("Error sending error report email: {0}", ex);
            }
        }
Esempio n. 12
0
        private void SendAlgorithmStatusNotifications(object state)
        {
            IMetaSettingRepository settingsRepository = _DataRepositoryFactory.GetDataRepository <IMetaSettingRepository>();
            string type = Constants.MetaSettings.Types.Communication;
            string code = Constants.MetaSettings.Codes.EmailSender;
            string name = settingsRepository.GetSetting(type, code).Value;

            string sender  = "*****@*****.**";
            string subject = "Algorithm Status Notifications";

            string body = "";

            _notifications.Distinct().ToList().ForEach(notification => body += string.Format("\n{0}", notification));

            using (IMailer mailer = _MailerFactory.GetMailer(name))
            {
                // refactor this later to send emails to all admins
                string recipients = "*****@*****.**";

                mailer.SendMail(sender, recipients, subject, body);
            }

            _notifications.Clear();
        }
Esempio n. 13
0
 public void SendMail(MailDTO dto, int id)
 {
     _mailer.SendMail(dto.Subject, dto.Body, id);
 }
Esempio n. 14
0
 //  メーラーとしての処理
 public static void FuncMailer(IMailer mailer)
 {
     mailer.SendMail();      //  メールを送信する
     mailer.RecieveMail();   //  メールを受信する
 }
Esempio n. 15
0
 public static void FuncMailer(IMailer mailer)
 {
     mailer.SendMail();
     mailer.RecieveMail();
 }
 private void ShowException(Exception exception)
 {
     Log.Error(exception, "Упс!");
     _mailer.SendMail(GetErrorMail(exception));
     _messenger.Error(exception.GetMessage());
 }