- Home /
Send mail from Unity5
Hi everyone, im trying to send email from C#, Unity5, but my unity always frezee, when i call send mail.
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class SentEmail : MonoBehaviour {
public string sender = "mail@gmail.com";
public string receiver = "mail@gmail.com";
public string smtpPassword = "password";
public string smtpHost = "smtp.gmail.com";
public void sentMail()
{
try
{
using (var mail = new MailMessage
{
From = new MailAddress(sender),
Subject = "test subject",
Body = "Hello there!"
})
{
mail.To.Add(receiver);
var smtpServer = new SmtpClient(smtpHost)
{
Port = 25,
Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword)
};
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
smtpServer.EnableSsl = true;
Debug.Log("HERE");
smtpServer.Send(mail);
Debug.Log("SUCCESFUL");
}
}
catch (Exception e)
{
Debug.Log(e.GetBaseException());
}
}
}
Debug with "HERE" works.. but others nothing, Can u help me?
Comment
Your answer
Follow this Question
Related Questions
Server certificates on Android question 1 Answer
SendMail from Android simply doesn't work 0 Answers
Validating Server Certificate Fail 0 Answers
Unity 5.6.7 - UnityWebRequest SSL/HTTPs 2 Answers
Guardar playerprefs en un servidor 0 Answers