C# 使用163的SMTP服务器发送邮件

string Receiver, string Subject, string content;

//163邮箱发送配置
client = new System.Net.Mail.SmtpClient();
client.Host = "smtp.163.com";
client.Port = 25;
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("****@163.com", "***");  //这里输入邮箱和授权码

System.Net.Mail.MailMessage Message = new System.Net.Mail.MailMessage();
Message.SubjectEncoding = System.Text.Encoding.UTF8;
Message.BodyEncoding = System.Text.Encoding.UTF8;
Message.Priority = System.Net.Mail.MailPriority.High;
Message.From = new System.Net.Mail.MailAddress("****@163.com");
//添加邮件接收人地址
string[] receivers = Receiver.Split(new char[] { ',' });
Array.ForEach(receivers.ToArray(), ToMail => { Message.To.Add(ToMail); });
Message.Subject = Subject;
Message.Body = content;
Message.IsBodyHtml = true;
client.Send(Message);

posted @ 2021-09-19 22:26  林冬  阅读(302)  评论(0编辑  收藏  举报