我在Microsoft文档(Core 2.1)中启动了“ ASP.NET Core中的帐户确认和密码恢复”主题,并编写了整个应用程序。但是,当我运行该应用程序时,我没有收到任何电子邮件。我在Sendgrid中建立了一个帐户,并在那里设置了密钥值。另外,我调试了该应用程序并观察了值,所有结果都是正确的。甚至新用户的用户名和密码也都以EmailConfirmation = false的形式保存在数据库中;我逐步遵循了所有说明以及所有调试电子邮件建议。但是我在收件箱(以及垃圾邮件和其他文件夹)中看不到任何确认电子邮件。您对我如何找到问题有任何建议吗?
这是主题的链接地址:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/accconfirm?view=aspnetcore-2.1
然后,我编写了以下控制台应用程序,但还是没事...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Mail;
using SendGrid;
using SendGrid.Helpers.Mail;
namespace ConsoleApp1
{
internal class Example
{
private static void Main()
{
Execute().Wait();
Console.Read();
}
static async Task Execute()
{
var client = new SendGridClient("my API Key I copied from sendgrid");
var from = new EmailAddress("my yahoo email which is my email used in sendgrid account", "my yahoo");
var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress("my gmail ", "my gmail");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
//Console.Read();
}
}
}
答案 0 :(得分:0)
我问Sendgrid,被告知我不能使用我的yahoo电子邮件(或gmail,...)作为发件人电子邮件;这是答案的一部分:“ Yahoo遵守称为DMARC的电子邮件安全标准。DMARC指示电子邮件提供商拒绝“发件人”域为Yahoo域但邮件来自未经批准的域服务器/服务的邮件。”所以我需要使用自己的邮件域;