问题描述
我是编程新手,我正在使用 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 (将#修改为@)