.net core 个人 smtp服务 邮件发送

1:开通个人smtp: 2:账户下开通smtp: 会发短信收到授权码:smurdizujnjgcacj(留着有用);3:干活来了:(代码比较简单)var client = new SmtpClient(smtp.qq.com) { Enabl...

1:开通个人smtp:

 

2:账户下开通smtp:

 

会发短信收到授权码:smurdizujnjgcacj(留着有用);

3:干活来了:(代码比较简单)

var client = new SmtpClient("smtp.qq.com")
{
EnableSsl = true,
UseDefaultCredentials = false,
Credentials = new System.Net.NetworkCredential("1632694570@qq.com", "smurdizujnjgcacj")
};
MailAddress from = new MailAddress("1632694570@qq.com", "磅管家科技", Encoding.UTF8);//初始化发件人
MailAddress to = new MailAddress("953706194@qq.com", "雷榕", Encoding.UTF8);//初始化收件人
////设置邮件内容
MailMessage message = new MailMessage(from, to)
{
Body = "测试",
BodyEncoding = Encoding.UTF8,
Subject = "测试",
SubjectEncoding = Encoding.UTF8,
IsBodyHtml = true
};
client.Send(message);

完成!

 

本文标题为:.net core 个人 smtp服务 邮件发送