邮箱验证 (给邮箱发送验证信息)

Posted liyi-dao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了邮箱验证 (给邮箱发送验证信息)相关的知识,希望对你有一定的参考价值。

#region
/// <summary>
/// 发送邮件验证码
/// </summary>
/// <param name="loginName"></param>
/// string smtpServer = "smtp.exmail.qq.com" + ""; //服务器地址
/// string uName = "发送方账号";
/// string uPwd = "发送方密码";
/// string fromMail = "发送方账号";
///  string toMail = “接受方账号”;
/// string subj = "标题";              
/// string bodys = "内容:
public static void SimpleSendEmail(string smtpServer, string uName, string uPwd, string fromMail, string toMail, string subj, string bodys) { try { //构造一个发件人地址对象 MailAddress from = new MailAddress(fromMail); //构造一个Email的Message对象 MailMessage message = new MailMessage(); //添加邮件主题和内容 message.From = from; string[] toEmailList = MySplit(toMail); for (int i = 0; i < toEmailList.Length; i++) { if (!string.IsNullOrEmpty(toEmailList[i])) { message.To.Add(toEmailList[i]); } } message.Subject = subj; message.SubjectEncoding = Encoding.UTF8; message.Body = bodys; message.BodyEncoding = Encoding.UTF8; message.IsBodyhtml = true; message.Priority = MailPriority.Normal;//优先级 //确定smtp服务器地址。实例化一个Smtp客户端 SmtpClient client = new SmtpClient(); client.Host = smtpServer; client.UseDefaultCredentials = true; //设置邮件的信息 client.DeliveryMethod = SmtpDeliveryMethod.Network; //用户登陆信息 System.Net.NetworkCredential myCredentials = new System.Net.NetworkCredential(uName, uPwd); client.Credentials = myCredentials; //发送邮件 client.Send(message); } catch (Exception e) { throw e; } } private static string[] MySplit(string a) { return a.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); } #endregion SendEmail

 

以上是关于邮箱验证 (给邮箱发送验证信息)的主要内容,如果未能解决你的问题,请参考以下文章

随机验证码图片验证码和邮箱发送用户验证码

发送邮箱验证信息的工具类

简述邮箱找回密码功能

保存邮箱并发送验证邮件

如何使用腾讯企业邮箱发送会员注册验证邮件

验证邮箱链接