繁体   English   中英

unity3d 发送电子邮件不起作用 c#

[英]unity3d sending email not working c#

我将介绍我自己,因为我是新手。

我的名字是 beau.. 我是一名游戏开发者,我还有一个叫做 VertexDevelopments 的团队。 我也在学习通用的 c# 而不是 c# unity。

所以这就是我被困的地方..

==================================问题============== ====================

我有一个叫做反馈的脚本。 我搜索了错误,但我找不到任何东西。

我会得到错误:

System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.InvalidOperationException: SSL authentication error: RemoteCertificateNotAvailable, RemoteCertificateChainErrors

在 System.Net.Mail.SmtpClient.m__4(System.Object 发件人,System.Security.Cryptography.X509Certificates.X509Certificate 证书,System.Security.Cryptography.X509Certificates.X509Chain 链,SslPolicyErrors sslPolicyErrors)[0x0000000000000000000000000

这是我目前拥有的代码:

public InputField yourEmail;
public InputField issue;

public MailMessage mail = new MailMessage();
public SmtpClient client = new SmtpClient("smtp.gmail.com");

public void SendingFeedback(){

    try {
        mail.From = new MailAddress(yourEmail.text.ToString());
        mail.To.Add("vertexdevelopments2016@gmail.com");
        mail.Subject = "test user";
        mail.Body = "this is for testing smpt mail from gmail";

        client.Port = 587;
        client.Host = "smtp.gmail.com";
        client.EnableSsl = true;
        client.Timeout = 1000;

        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.UseDefaultCredentials = false;

        mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

        client.Send(mail);
    }

    catch(Exception ex){
        Debug.Log (ex);
    }
}

================================================== ========================

在我使用的课程之上:

  • 统一引擎;
  • UnityEngine.UI;

  • 系统;

  • System.Collections;
  • System.Net.Mail;
  • System.Net.Sockets;
  • 系统文本;

我希望我对这个问题有足够的了解......

也是非常美好的一天,

您确定要启用 SSL,如下所示:

client.EnableSsl = true;

错误说它找不到根证书。

您还需要将登录凭据应用于 gmail。

感谢您的快速回复.. 但我认为应该是 client.EnableSsl 需要更改为 false..

但如果我将其设置为 false,我会收到此错误:

问题如果是假的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM