美文网首页
Unity发送错误日志到QQ邮箱

Unity发送错误日志到QQ邮箱

作者: 东丶野 | 来源:发表于2017-07-10 12:04 被阅读0次
开启QQ邮箱SMTP功能
找到QQ邮箱里面的设置->账户->然后找到如下图的发送短信到腾讯开启SMTP功能
Paste_Image.png
Unity端发送邮件到邮箱

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Net.Mail;
using System.Text;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Net;

public class EmailErrorLog : MonoBehaviour {
void OnGUI()
{
if (GUI.Button(new Rect(0, 0, 100, 40), "Send"))
{
SendEmail("主城异常崩溃日志");
}
}

string mailAddress ="511950082@qq.com";
string smtpPassword = "mebcobswrtlmbhee";
object token = new object ();
private void SendEmail(string body)
{
MailMessage mail = new MailMessage();

mail.From = new MailAddress(mailAddress);
mail.To.Add(mailAddress);
mail.Subject = "<<武当剑>> 错误日志收集";
mail.Body = body;

SmtpClient smtpServer = new SmtpClient("smtp.qq.com");
smtpServer.Credentials = new System.Net.NetworkCredential(mailAddress, smtpPassword) as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){ return true; };
// smtpServer.Send(mail); //同步发送
smtpServer.SendAsync (mail, token); //异步发送
Debug.Log("发送成功");
}
}

 补充:发现手机上的时候发送不了邮件,报错信息如下
 _wapi_gethostbyname: Need to translate 0 into winsock error
 修改:playersettings 那里需要设置network access 为requried

相关文章

网友评论

      本文标题:Unity发送错误日志到QQ邮箱

      本文链接:https://www.haomeiwen.com/subject/xipyhxtx.html