Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void SendRecoveryEmail()
- {
- try
- {
- GenerateKey(10);
- MailMessage recoveryMail = new MailMessage();
- recoveryMail.From = new MailAddress("sqlunityclasssydney@gmail.com");
- //Should be replaced with email string field. Jays Email In Case"jaymieraesargent@gmail.com"
- recoveryMail.To.Add(s_Email);
- recoveryMail.Subject = "Password Reset";
- 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";
- SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
- smtpServer.Port = 25;
- smtpServer.Credentials = new System.Net.NetworkCredential("sqlunityclasssydney@gmail.com", "sqlpassword") as ICredentialsByHost;
- smtpServer.EnableSsl = true;
- ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors) { return true; };
- smtpServer.Send(recoveryMail);
- Debug.Log("Sent Email");
- NewUiEvent("Email Has Been Sent");
- cur = 6;
- }
- catch
- {
- NewUiEvent("Email Couldn't Send");
- }
- }
- public string GenerateKey(int len)
- {
- string[] constants = { "b", "bb", "c", "d", "f", "g", "a", "e", "i", "o", "u", "y", "h", "j", "k", "l", "ll",
- "m", "n", "p", "r", "rr", "s", "sh", "zh", "t", "tt", "w", "ie", "ee", "ae", "i", "o", "y", "io" };
- string[] consonantsUpper = { "B", "C", "D", "F", "G", "H", "J", "K", "L", "X", "M", "N", "P", "R", "S", "T", "V", "W", "Z" };
- string[] numbers = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
- string cur_Key = "";
- int c;
- int randomNum;
- for (int i = 0; i < len; i++)
- {
- randomNum = UnityEngine.Random.Range(0, 3);
- if(randomNum == 0)
- {
- c = UnityEngine.Random.Range(0, constants.Length - 1);
- cur_Key += constants[c];
- }
- else if (randomNum == 1)
- {
- c = UnityEngine.Random.Range(0, consonantsUpper.Length - 1);
- cur_Key += consonantsUpper[c];
- }
- else
- {
- c = UnityEngine.Random.Range(0, numbers.Length - 1);
- cur_Key += numbers[c];
- }
- }
- generatedCode = cur_Key;
- return cur_Key;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement