1
下面的C#代码VS2017
显示邮件已成功发送。我可以从我的outlook
帐户的发件箱中验证电子邮件确实已成功发送。但是在我的Yahoo
帐户中,即使超过一个小时,电子邮件也不存在。 问题:东西在这里我的代码缺少 - 我们怎样才能使它发挥作用? 注意:我已经在我的Outlook的发件箱,无论From
和To
邮件地址是正确的验证。我正在关注这个Technet article。MailKit显示邮件发送,但没有收到 - .NET核心1.1
static void Main(string[] args)
{
try
{
//From Address
string FromAddress = "[email protected]";
string FromAdressTitle = "Email from ASP.NET Core 1.1";
//To Address
string ToAddress = "[email protected]";
string ToAdressTitle = "Microsoft ASP.NET Core";
string Subject = "Hello World - Sending email using ASP.NET Core 1.1";
string BodyContent = "ASP.NET Core was previously called ASP.NET 5. It was renamed in January 2016. It supports cross-platform frameworks (Windows, Linux, Mac) for building modern cloud-based internet-connected applications like IOT, web apps, and mobile back-end.";
//Smtp Server
string SmtpServer = "smtp.live.com";
//Smtp Port Number
int SmtpPortNumber = 587;
var mimeMessage = new MimeMessage();
mimeMessage.From.Add(new MailboxAddress(FromAdressTitle, FromAddress));
mimeMessage.To.Add(new MailboxAddress(ToAdressTitle, ToAddress));
mimeMessage.Subject = Subject;
mimeMessage.Body = new TextPart("plain")
{
Text = BodyContent
};
using (var client = new SmtpClient())
{
client.Connect(SmtpServer, SmtpPortNumber, false);
// Note: only needed if the SMTP server requires authentication
// Error 5.5.1 Authentication
client.Authenticate(FromAddress, "myFromEmailpassword");
client.Send(mimeMessage);
Console.WriteLine("The mail has been sent successfully !!");
Console.ReadLine();
client.Disconnect(true);
}
}
catch (Exception ex)
{
throw ex;
}
}
雅虎和其他网络邮件服务器有时会重新写从头。此外,MailKit无法控制雅虎发送邮件需要多长时间 - 应该不需要一个小时,但谁知道雅虎邮箱正在做什么? – jstedfast