标签:als set sage .net extend address add default uap
之前也发布过一篇QQ发邮件的,后来那种方法在阿里云服务器中报错了,查了好久才发现,是阿里云的服务器把 25 端口 给封杀了。现在重新做了个功能。
public static string UserName = ""; public static string UserPass = ""; /// <summary> /// 向用户发送邮件 /// </summary> /// <param name="ReceiveUser">接收邮件的用户</param> /// <param name="MailTitle">发送标题</param> /// <param name="valiCode">发送的验证码</param> /// <returns>bool</returns> public static bool sendMail(string ReceiveUser, string MailTitle, string valiCode) { //保存验证码 var authCode = valiCode; UAP.Session.Set("authCode", valiCode); MailAddress toMail = new MailAddress(ReceiveUser); MailAddress fromMail = new MailAddress(UserName, "51流量神器"); MailMessage mail = new MailMessage(fromMail, toMail); mail.Subject = MailTitle; mail.IsBodyHtml = true; mail.Body = "【" + MailTitle + "】您好,您的验证码是:" + valiCode + " ."; ; SmtpClient client = new SmtpClient(); client.Host = "smtp.exmail.qq.com"; client.Port = 587; //25 端口已被阿里云全面封杀 client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(UserName, UserPass); client.DeliveryMethod = SmtpDeliveryMethod.Network; try { client.Send(mail); return true; } catch(Exception ex) { Extend.WriteTextLog("SendEmail", ex.Message, DateTime.Now, "Email_Error"); throw; } }
标签:als set sage .net extend address add default uap
原文地址:https://www.cnblogs.com/freedom-ly/p/9900131.html