简体   繁体   中英

unity3d sending email not working c#

i will introduce my self because i'm new to this..

my name is beau.. and i am a Game Developer and i have also a team that called VertexDevelopments. i am also learning the general c# instead of c# unity.

so this is where i am stuck..

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

i have a script that called feedback. i searched for the error but i can't find anything.

i will get the error :

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

at System.Net.Mail.SmtpClient.m__4 (System.Object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors sslPolicyErrors) [0x00000] in :0

and this is the code what i currently have :

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);
    }
}

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

above the class i used :

  • UnityEngine;
  • UnityEngine.UI;

  • System;

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

i hope i informed enough about this issue...

and also a very nice day,

Beau

Are you sure, you want to enable SSL, as you do:

client.EnableSsl = true;

The error says it can't find a root certificate.

Also you need to apply login credentials to gmail.

Thank you for the fast reply.. but i think should be the client.EnableSsl needs to be changed to false..

but if i set it to false i will get this error :

ISSUE if false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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