当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - SocketException: No such host is known - Failed to send email - unity

问题描述:

public void EmailSending() {

MailMessage mail = new MailMessage();

mail.From = new MailAddress("[email protected]");

mail.To.Add("[email protected]");

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 protected]", "pw") as ICredentialsByHost;

smtpServer.EnableSsl = true;

ServicePointManager.ServerCertificateValidationCallback =

delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

{ return true; };

smtpServer.Send(mail);

Debug.Log("success");

}

I am getting this error

SocketException: No such host is known.

System.Net.Dns.hostent_to_IPHostEntry (System.String h_name,

System.String[] h_aliases, System.String[] h_addrlist)

网友答案:

if you have sending from anroid device then I think you have same problem some time, make sure your android build asks for Internet Access permission.

Go to Android Player Settings, "Other settings" and look for Internet Access. It's "Auto" by default, set it to "Require".

分享给朋友:
您可能感兴趣的文章:
随机阅读: