- Home /
Send email works in Editor, not on tablet
This is my code :
void Mail(){
MailMessage mail = new MailMessage();
mail.From = new MailAddress("aaaaa@gmail.com");
mail.To.Add("bbbb@.com.vn");
mail.Subject = "Hello!!!";
mail.Body = "This is word and image for you.";
string attachmentPath = filename;
Debug.Log(attachmentPath);
Attachment attachmentFile = new Attachment(attachmentPath);
mail.Attachments.Add(attachmentFile);
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
#if UNITY_IPHONE
smtpServer.Credentials = new System.Net.NetworkCredential("aaaaaaaa@gmail.com", "xxxxxxxxx") as ICredentialsByHost;
#endif
#if UNITY_EDITOR_WIN
smtpServer.Credentials = new System.Net.NetworkCredential("aaaaaaaa@gmail.com", "xxxxxxxxx") as ICredentialsByHost;
#endif
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
}
I run on unity3d ==> it is good.
I build into ios,android ==> install on device ==> run ==> it is error ( i don't see email )
Why?? and Why??.
Comment
Answer by tanoshimi · May 20, 2015 at 05:51 PM
Have you followed all the advice in http://answers.unity3d.com/questions/46752/unity-3-sending-email-with-c.html
(Particularly in the last answer)
Answer by codemaker2015 · Dec 21, 2021 at 02:53 PM
Ensure that you have changed Internet access from auto to require in Player settings --> other settings --> configuration
Use this reference to create application specified password.