I am having this issue each time when i try to register new users to my web application. Here is the logic.
- <connectionStrings>
- <add name="DefaultConnection" connectionString="Data Source=GcobaniM-L\SQLEXPRESS;Initial Catalog=eNtsaRegistration;Integrated Security=True" providerName="System.Data.SqlClient" />
- </connectionStrings>
-
- public Task SendAsync(IdentityMessage message)
- {
-
- var mailMessage = new MailMessage();
- mailMessage.To.Add(new MailAddress(message.Destination));
- mailMessage.From = new MailAddress("[email protected]");
- mailMessage.Subject = message.Subject;
- mailMessage.IsBodyHtml = true;
- mailMessage.Body = message.Body;
- using (var smtp = new SmtpClient())
- {
- var credential = new NetworkCredential
- {
- UserName = "[email protected]",
- Password = "***"
- };
- smtp.Host = "smtp.gmail.com";
- smtp.Port = 587;
- smtp.EnableSsl = true;
- smtp.UseDefaultCredentials = false;
- smtp.Credentials = credential;
- smtp.Send(mailMessage);
- }
- return Task.FromResult(0);
- }
- }