微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MailKit 在 dotnet 核心中不起作用

如何解决MailKit 在 dotnet 核心中不起作用

我是编程新手,我正在使用 dotnet core 5 构建一个 web api 项目。我已经安装了 MailKit 以发送电子邮件,但它不起作用。这是我的配置:

 services.AddMailKit(config =>
        {
            config.UseMailKit(configuration.GetSection("Email").Get<MailKitOptions>());
        });

还有我的应用设置:

    {
  "ConnectionStrings": {
    "xxxxxxx"
  },"Email": {
    "Server": "smtp.gmail.com","Port": 465,"SenderName": "xxxx","SenderEmail": "xxxx@gmail.com","Account": "xxxx","Password": "xxxx","Security": true
  },"JWT": {
    "ValidAudience": "User","Validissuer": "https://localhost:5001","Secret": "aslkjsdfl;afa;falkajs"
  },"Logging": {
    "LogLevel": {
      "Default": "information","Microsoft": "Warning","Microsoft.Hosting.Lifetime": "information"
    }
  },"AllowedHosts": "*"
}

我的 gmail 密码和地址是正确的。此外,我在谷歌帐户中启用了安全性较低的应用程序。以下是我发送电子邮件的方式:

await _emailService.SendAsync(user.Email,"Email Verification",emailVereificationLink);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。