when i call this script the unity editor freezes and the program is shown as not responding in the task manager and also it does the same thing in the webGL build when the script is called. I cant get any error messages because it just freezes. I got this code from another help topic that stated it worked. Not sure what i did wrong. (i changed the email and password to a default value in this post for security issues)
public class mono_gmail : MonoBehaviour
{//this script will send an email to a gmail address when called
public void Send_Mail()
{ // set Api Compatibility Level to ".NET 2.0" instead of ".NET 2.0 Subset" under player settings
try
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("email@gmail.com");
mail.To.Add("email@gmail.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential("email@gmail.com", "password") as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
}
catch(Exception ex) {
Console.WriteLine(ex.Message);
throw ex;
}
Debug.Log("success");
}
}
↧