邮件不是从统一C#发送的

时间:2018-11-03 08:28:45

标签: c# unity3d

我正在尝试通过统一C#发送邮件。我正在使用此代码:

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

但是邮件尚未开始发送到Recipient。我还在我的Gmail帐户中启用了“允许减少应用程序的安全性”。

但是邮件没有被发送。...

感谢您的帮助

0 个答案:

没有答案