Unity发送错误日志到QQ邮箱

开启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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,131评论 19 139
  • 概述 在多数移动应用中任何时候都只能有一个应用程序处于活跃状态,如果其他应用此刻发生了一些用户感兴趣的那么通过通知...
    莫离_焱阅读 6,598评论 1 8
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,081评论 0 23
  • 受伤的女人:去年未见雪花飘,一色孤梅泪落朝。拜赏无人风雨吵,虫儿梦醒报春消。
    寒梅热血阅读 175评论 0 0
  • 98B期/137期/149期/161期/170B期 英德市可立克電子有限公司 【日精進打卡第365天】 【知~學習...
    樂然阅读 186评论 0 1