- Home /
Question by
sekmano · Dec 09, 2017 at 09:21 PM ·
c#guinetworkingmonodevelopemail
Problem in sending email using unity
I create a simple C# script in MonoDevelop to send email to gmail, the program work without any problem and i can send any email to gmail but when i build project and run the .exe software i can't send any email and i don't know the problem here some screen shot this is the .exe software in my pc
here the sript
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using UnityEngine.UI;
public class email : MonoBehaviour {
public Text txt;
string i="success";
public void send(string i)
{
MailMessage mail = new MailMessage ();
mail.From = new MailAddress ("youremail@gmail.com");
mail.To.Add ("receiverEmail@gmail.com");
//mail.Subject = "Winik";
mail.Body = i;
SmtpClient smtpServer = new SmtpClient ("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential ("youremail@gmail.com", "password") as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
return true;
};
smtpServer.Send (mail);
Debug.Log ("seccess");
TextSucces ();
}
here the result in console
upload-2017-12-9-21-59-11.png
(235.4 kB)
sans-titre.png
(32.7 kB)
Comment