i am done email sending after submit the form.but i can`t send otp to email.
- [AllowAnonymous]
- [Route("Register")]
- public async Task<IHttpActionResult> Register(RegisterBindingModel model)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
-
- var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };
-
- IdentityResult result = await UserManager.CreateAsync(user, model.Password);
-
- if (!result.Succeeded)
- {
- return GetErrorResult(result);
- }
- MailMessage mm = new MailMessage("fromemail", "toemail");
- mm.Subject ="Leave Reject";
- mm.Body = "Hi Sir, " ;
- mm.IsBodyHtml = false;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Port = 587;
- smtp.UseDefaultCredentials = false;
- smtp.Credentials = new System.Net.NetworkCredential("email", "password");
- smtp.EnableSsl = true;
- smtp.Send(mm);
-
- return Ok();
- }