I am trying to send mail through unity C#. I am using this code:
void SendEmail()
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress(from);
mail.To.Add(to);
mail.Subject = "Password Verification";
mail.Body ="Password Number";
SmtpClient smtpServer = new SmtpClient(smtp);
smtpServer.Port = 587;
smtpServer.EnableSsl = true;
smtpServer.Credentials = new System.Net.NetworkCredential(from, password) as ICredentialsByHost;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object obj, X509Certificate cert, X509Chain chain, SslPolicyErrors sslerrors)
{ return true; };
smtpServer.Send(mail);
#if UNITY_EDITOR
Debug.Log("email sent");
#endif
SetEmailing(false);
}
But mail is not begin sent to the Recipient
. I have also enabled the "Allow secure less apps" in my Gmail account.
But mail is not being sent....
Any help is appreciated