Public Async Function Register(model As RegisterViewModel) As Task(Of ActionResult)
If ModelState.IsValid Then
Dim user = New ApplicationUser() With {
.UserName = model.Email,
.Email = model.Email
}
Dim result = Await UserManager.CreateAsync(user, model.Password)
If result.Succeeded Then
Await SignInManager.SignInAsync(user, isPersistent:=False, rememberBrowser:=False)
' For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
' Send an email with this link
Dim code = Await UserManager.GenerateEmailConfirmationTokenAsync(user.Id)
Dim callbackUrl = Url.Action("ConfirmEmail", "Account", New With {.userId = user.Id, .code = code}, protocol:=Request.Url.Scheme)
UserManager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=""" & callbackUrl & """>here</a>")
Return RedirectToAction("Index", "Home")
End If
AddErrors(result)
End If
' If we got this far, something failed, redisplay form
Return View(model)
End Function
这是标准注册码
现在我已经在web.config中设置了我的SMTP,我甚至测试了其他服务/电子邮件程序的详细信息并且它有效
<system.net>
<mailSettings>
<smtp from="*@ziggo.nl" deliveryMethod="Network">
<network defaultCredentials="true" host="smtp.ziggo.nl" port="587" userName="*@ziggo.nl" password="*" enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
现在这是我使用的smtp设置。我隐藏了我的个人详细信息*但我想知道为什么邮件没有通过UserManager发送.SendEmail