//
// POST: /Account/ForgotPassword
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
{
if (ModelState.IsValid)
{
var user = await UserManager.FindByNameAsync(model.Email);
// if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
if( user == null )
{
ModelState.AddModelError("","El correo es invalido");
// Don't reveal that the user does not exist or is not confirmed
return View("ForgotPasswordConfirmation");
}
// For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
// Send an email with this link
string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");
return RedirectToAction("ForgotPasswordConfirmation", "Account");
}
// If we got this far, something failed, redisplay form
return View(model);
}
public class EmailService : IIdentityMessageService
{
public Task SendAsync(IdentityMessage message)
{
// Credentials:
var envia = "[email protected]";
var user = "[email protected]";
var pass = "contraseña";
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential( user, pass );
SmtpClient client = new SmtpClient()
{
Host = "smtp.live.com",
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Port = 25,
EnableSsl = true,
Credentials = credentials
};
var mail = new MailMessage(envia, message.Destination);
mail.Subject = message.Subject;
mail.Body = message.Body;
mail.IsBodyHtml = true;
return client.SendMailAsync(mail);
}
}
El error que me da es el siguiente:
Error en la transacción. La respuesta del servidor fue: 5.2.0 STOREDRV.Submission.Exception:OutboundSpamException; Failed to process message due to a permanent exception with message WASCL UserAction verdict is not None. Actual verdict is Suspend, ShowTierUpgrade. OutboundSpamException: WASCL UserAction verdict is not None. Actual verdict is Suspend, ShowTierUpgrade. [Hostname=CY4PR05MB3414.namprd05.prod.outlook.com]
Error de código fuente:
Línea 315: await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here");