Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SocketException:未知此类主机-无法发送电子邮件-unity_C#_Unity3d_Smtp - Fatal编程技术网

C# SocketException:未知此类主机-无法发送电子邮件-unity

C# SocketException:未知此类主机-无法发送电子邮件-unity,c#,unity3d,smtp,C#,Unity3d,Smtp,我得到了这个错误 SocketException:不知道这样的主机 public void EmailSending() { MailMessage mail = new MailMessage(); mail.From = new MailAddress("xxx@gmail.com"); mail.To.Add("xxx@gmail.com"); mail.Subject = "Test Mail"; mail.Body = "This is for

我得到了这个错误


SocketException:不知道这样的主机

public void EmailSending() {
    MailMessage mail = new MailMessage();

    mail.From = new MailAddress("xxx@gmail.com");
    mail.To.Add("xxx@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("xxx@gmail.com", "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");
}
System.Net.Dns.hostent_to_IPHostEntry(System.String h_name, System.String[]h_别名,System.String[]h_地址列表)


如果您已从anroid设备发送,则 我想你也会遇到同样的问题,确保你的android版本需要互联网访问许可

转到Android播放器设置,“其他设置”并查找互联网接入。默认为“自动”,将其设置为“需要”。

错误


SocketException:不知道这样的主机

public void EmailSending() {
    MailMessage mail = new MailMessage();

    mail.From = new MailAddress("xxx@gmail.com");
    mail.To.Add("xxx@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("xxx@gmail.com", "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");
}

由于代理服务器而发生。我的IP位于代理服务器后面,在分配直接internet访问后,代码工作正常。

SocketException:没有已知的此类主机

public void EmailSending() {
    MailMessage mail = new MailMessage();

    mail.From = new MailAddress("xxx@gmail.com");
    mail.To.Add("xxx@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("xxx@gmail.com", "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");
}

解决方案:Internet无法执行该操作。检查您的互联网

在我的情况下,我的互联网连接非常低。

您从哪里获得的端口设置?您是否尝试了端口
465
我将其更改为465,它仍然显示相同的错误我发现了一些其他问题,您必须在播放器设置下将Api兼容级别设置为“.NET 2.0”,而不是“.NET 2.0子集”。希望其他人也能从中得到帮助。请使用这是关于webgl的我已经检查过了我没有使用webgl我正在使用一个应用程序