public ActionResult Contact(ContactViewModel model) { if (ModelState.IsValid) { DebugMailService service = new DebugMailService(); service.SendMail(model.Email, model.Name, "Hello", model.Message); } ModelState.Clear(); ViewBag.Message = "Mail Sent . Thanks !!"; return(View()); }
public void TestSendTask() { Debug.WriteLine($"Ожидаем {DateTime.Now:F}...."); Debug.WriteLine($"ОТПРАВКА {DateTime.Now:F}...."); var mailService = new DebugMailService(); var sc = new SchedulerClass(); sc.SendTask(senderTasks, mailService); var countExpected = 20; var countSend = senderTasks.Sum(x => x.IsSendEnd ? 1 : 0); Assert.AreEqual(countExpected, countSend); }
public async Task <IActionResult> Registration(/*[FromForm]*/ RegisterViewModel vm, string returnUrl) { if (vm.Email.Contains("aol.com") || vm.Email.Contains("amail.com")) { ModelState.AddModelError("", "We don't support this email domain addresses "); } if (ModelState.IsValid) { if (await _userManager.FindByEmailAsync(vm.Email) == null) { WorldUser user = Mapper.Map <WorldUser>(vm); var result = await _userManager.CreateAsync(user, vm.Password); if (result.Succeeded) { var codes = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action( "ConfirmEmail", "Signup", new { userId = user.Id, code = codes }, protocol: HttpContext.Request.Scheme ); DebugMailService mailService = new DebugMailService(); await mailService.ConfirmationByEmailMsgAsync(vm.Email, "Confirm Your account, please.", $"Confirm registration folowing the link: <a href='{callbackUrl}'>Confirm email NOW</a>"); return(RedirectToAction("Index", "App")); } else { foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } } else { ModelState.AddModelError(vm.Email, "This email is already registered!"); } } return(View(vm)); }