- Home /
Unknown Host Exception when attempting to send a mail from Android, but not editor
This is the method in which i send mail
public static void sendMail(string title, string data){
MailMessage mail = new MailMessage();
mail.From = senderMail;
mail.To.Add (receiverMail);
mail.Subject = title;
mail.Body = data;
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential(sender, password) as ICredentialsByHost;
client.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
client.Send(mail);
Debug.Log("success");
}
In the editor I don't get this error at all, but in Android I get this error :
I/Unity ( 3719): SocketException: No such host is known
I/Unity ( 3719): at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in :0
I/Unity ( 3719): at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in :0
I/Unity ( 3719): at System.Net.Dns.GetHostAddresses (System.String hostNameOrAddress) [0x00000] in :0
I/Unity ( 3719): at Mailer.sendMail (System.String title, System.String data) [0x00000] in :0
I/Unity ( 3719): at Mailer.Start () [0x00000] in :0
If you can help me out that would be great. Thanks in Advance
Your answer
Follow this Question
Related Questions
Sending email from within Unity using smtp service 1 Answer
Can't access to gmail using the build 1 Answer
how the player control on volume in the game? 1 Answer
putting main camera head 0 Answers