标签:
public ActionResult Index() { /*第一种,利用Google的smtp来发送邮件*/ SmtpClient client = new SmtpClient("smtp.163.com", 25); Random Rdm = new Random(); //产生0到100的随机数 int iRdm = Rdm.Next(99999, 100000); MailMessage msg = new MailMessage("邮箱@163.com", "接收的邮箱", "验证码", iRdm.ToString()); client.UseDefaultCredentials = false; System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("163邮箱注册的账号", "163邮箱注册的密码");
client.Credentials = basicAuthenticationInfo; client.EnableSsl = true; client.Send(msg); return Content("s"); }
要发送邮箱,首先要在163邮箱注册一个账号,用这个账号就可以发邮箱了。。
标签:
原文地址:http://www.cnblogs.com/fxd980519/p/4959508.html