Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. public void SendRecoveryEmail()
  13. {
  14. try
  15. {
  16. GenerateKey(10);
  17. MailMessage recoveryMail = new MailMessage();
  18. recoveryMail.From = new MailAddress("sqlunityclasssydney@gmail.com");
  19. //Should be replaced with email string field. Jays Email In Case"jaymieraesargent@gmail.com"
  20. recoveryMail.To.Add(s_Email);
  21. recoveryMail.Subject = "Password Reset";
  22. recoveryMail.Body = "Hello " + s_Username + Environment.NewLine + "Your acount recovery details are as below:" + Environment.NewLine + "Username: " + s_Username + Environment.NewLine + "Password:" + generatedCode + Environment.NewLine + "Thank You , Phabulous Studios";
  23. SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
  24. smtpServer.Port = 25;
  25. smtpServer.Credentials = new System.Net.NetworkCredential("sqlunityclasssydney@gmail.com", "sqlpassword") as ICredentialsByHost;
  26. smtpServer.EnableSsl = true;
  27. ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors) { return true; };
  28. smtpServer.Send(recoveryMail);
  29. Debug.Log("Sent Email");
  30. NewUiEvent("Email Has Been Sent");
  31. cur = 6;
  32. }
  33. catch
  34. {
  35. NewUiEvent("Email Couldn't Send");
  36. }
  37. }
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. public string GenerateKey(int len)
  51. {
  52. string[] constants = { "b", "bb", "c", "d", "f", "g", "a", "e", "i", "o", "u", "y", "h", "j", "k", "l", "ll",
  53. "m", "n", "p", "r", "rr", "s", "sh", "zh", "t", "tt", "w", "ie", "ee", "ae", "i", "o", "y", "io" };
  54. string[] consonantsUpper = { "B", "C", "D", "F", "G", "H", "J", "K", "L", "X", "M", "N", "P", "R", "S", "T", "V", "W", "Z" };
  55. string[] numbers = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  56. string cur_Key = "";
  57. int c;
  58. int randomNum;
  59. for (int i = 0; i < len; i++)
  60. {
  61. randomNum = UnityEngine.Random.Range(0, 3);
  62. if(randomNum == 0)
  63. {
  64. c = UnityEngine.Random.Range(0, constants.Length - 1);
  65. cur_Key += constants[c];
  66. }
  67.  
  68. else if (randomNum == 1)
  69. {
  70. c = UnityEngine.Random.Range(0, consonantsUpper.Length - 1);
  71. cur_Key += consonantsUpper[c];
  72. }
  73.  
  74. else
  75. {
  76. c = UnityEngine.Random.Range(0, numbers.Length - 1);
  77. cur_Key += numbers[c];
  78. }
  79. }
  80. generatedCode = cur_Key;
  81. return cur_Key;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement