相关疑难解决方法(0)

UserManager SendEmailAsync没有发送电子邮件

我使用以下代码尝试异步发送电子邮件,但没有发送电子邮件,我不确定是什么做错了.我还在web.config中为电子邮件协议添加了第二段代码.

SendEmailAsync代码

await UserManager.SendEmailAsync(username.Id, "MTSS-B: Forgot Password", "Here is your new password. Please go back to the MTSS-B web tool and sign in. You will be prompted to create your own password.<br/><br/>" + tmpPass + "<br/><br/>MTSS-B Administrator");
Run Code Online (Sandbox Code Playgroud)

Web.config代码

<system.net>
<mailSettings>
  <smtp>
    <network host="smtp1.airws.org" userName="" password="" />
  </smtp>
</mailSettings>
</system.net>
Run Code Online (Sandbox Code Playgroud)

********更新

我测试了是否可以使用常规方法发送电子邮件,并且可以使用以下代码发送电子邮件.

MailMessage m = new MailMessage(new MailAddress(ConfigurationManager.AppSettings["SupportEmailAddr"]), new MailAddress(model.Email));
m.Subject = "MTSS-B: Forgot Password"; 
m.Body = string.Format("Here is your new password. Please go back to the MTSS-B web tool and …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

25
推荐指数
3
解决办法
3万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1