I have this issue, each time i am registering the new user, its connection failure to third party. I am using smtp client mail and this domain is gmail. The question why am i getting this often and its not even send a confirming email to the user. It does writes this query to the database colum. What could an issue?
- [HttpPost]
- [AllowAnonymous]
- [ValidateAntiForgeryToken]
- public async Task<ActionResult> Register(RegisterViewModel model)
- {
- if (ModelState.IsValid)
- {
- var user = new ApplicationUser() { UserName = model.UserName };
- user.Email = model.Email;
- user.ConfirmedEmail = false;
- var result = await UserManager.CreateAsync(user, model.Password);
- if (result.Succeeded)
- {
- System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(
- new System.Net.Mail.MailAddress("[email protected]", "Web Registration"),
- new System.Net.Mail.MailAddress(user.Email));
- m.Subject = "Email confirmation";
- m.Body = string.Format("Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>", user.UserName, Url.Action("ConfirmEmail", "Account", new { Token = user.Id, Email = user.Email }, Request.Url.Scheme));
- m.IsBodyHtml = true;
- System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
- smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
- smtp.EnableSsl = true;
- smtp.Send(m);
- return RedirectToAction("Confirm", "Account", new { Email = user.Email });
- }
- else
- {
- AddErrors(result);
- }
- }
-
-
- return View(model);
- }
