- Home /
 
iOS email sending
Hello!
I am working on a project which needs to send emails from an iOS/Android mobile device using Unity. The code that I made works in both the Unity Editor and on my Android device. However, it does not work on the iOS.
Here is the code that I am using:
 if (checkForInternet ()) {
             PlayerPrefs.SetInt ("internetActive", 1);
             mail.From = new MailAddress ("senderAddres@gmail.com");
             mail.To.Add ("receiverAddres@gmail.com"); 
 
             SmtpClient smtpServer = new SmtpClient ("smtp.gmail.com");
             smtpServer.Port = 587;
             mail.Subject = "Subject";
             mail.Body = "Email body: \n \n" + name.text;
             smtpServer.Credentials = new System.Net.NetworkCredential ("senderAddres@gmail.com", "password") as ICredentialsByHost;
             smtpServer.EnableSsl = true;
             ServicePointManager.ServerCertificateValidationCallback =
             delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
                 return true;
             };
             smtpServer.Send (mail);
             infoText.text = "Complete.";
             Send.SetActive (false);
             Cancel.SetActive (false);
             Exit.SetActive (true);
         } else 
             infoText.text = "No internet connection available.";
 
               In the iOS version, pressing the button that triggers the code that I mention above does nothing. After doing some research it seems that some people fixed this issue by setting the API Compatibility Level to 2.0., I did that, however that did not fix the iOS problem.
Thank you very much for your help!
               Comment
              
 
               
              Your answer