unity3d发送电子邮件不工作c#

时间:2016-04-23 20:57:45

标签: c#

我将介绍我的自我,因为我是新手......

我的名字很友好..我是一名游戏开发者,我还有一个名为VertexDevelopments的团队。我也在学习c#而不是c#unity。

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

================================== ISSUE ============ ======================

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

我会收到错误:

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 sender,System.Security.Cryptography.X509Certificates.X509Certificate证书,System.Security.Cryptography.X509Certificates.X509Chain chain,SslPolicyErrors sslPolicyErrors)[0x00000] in:0

这是我目前拥有的代码:

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;
  • UnityEngine.UI;

  • 系统;

  • System.Collections中;
  • System.Net.Mail;
  • 的System.Net.Sockets;
  • System.Text;

我希望我能够充分了解这个问题...

也是一个美好的一天,

2 个答案:

答案 0 :(得分:0)

您确定要启用SSL吗?

//This is the array with multiple elements
var array1=["word1" , "word2" , "word3" , "word4" , "word5" , "word6" ];

$(function () {
  $("#btn1").on('click', function(e) {
    // disable button till the operation is completed
    $(this).prop('disabled', 'disabled');
    
    // use data-currentIndex to store the local variable i
    var idx = $('#change').data('currentIndex');
    if (idx === undefined) {
      idx = 0;
    }
    $('#change').fadeOut('slow', function() {
      $(this).text(array1[idx]).fadeIn('slow');
      idx = (idx <= (array1.length - 2)) ? (idx + 1) : 0;
      $('#change').data('currentIndex', idx);
      
      // enable button because the operation is now completed
      $("#btn1").removeProp('disabled');
    });
  });
});

错误说它无法找到根证书。

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

答案 1 :(得分:-1)

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

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

ISSUE if false