Unity中用新浪邮箱给用户发送邮件(和QQ邮箱发送稍有不同)

QQ邮箱发送邮件请参考:

https://blog.csdn.net/wk201403010114/article/details/83543770

 //新浪
        MailMessage mail = new MailMessage();
        //发送邮箱的地址
        mail.From = new MailAddress("发送邮件的新浪邮箱账号");
        //收件人邮箱地址 如需发送多个人添加多个Add即可
        mail.To.Add(收件人的邮箱);
        //标题
        mail.Subject = "Title";
        //正文
        mail.Body = "尊敬的用户,您的登录密码是:\n" + pass+",请妥善保管!";
        //添加一个本地附件 (这个我没用,可以研究一下)
        //mail.Attachments.Add(new Attachment(UnityPath));

        //所使用邮箱的SMTP服务器
        SmtpClient smtpServer = new SmtpClient("smtp.sina.com");
        //SMTP端口
        smtpServer.Port = 587;//或者465
        //账号密码 一般邮箱会提供一串字符来代替密码
        smtpServer.Credentials = new System.Net.NetworkCredential("发送邮件的新浪邮箱账户", "新浪邮箱的登录密码") as ICredentialsByHost;
        smtpServer.EnableSsl = true;
        System.Net.ServicePointManager.ServerCertificateValidationCallback =
            delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            { return true; };

        smtpServer.Send(mail);

猜你喜欢

转载自blog.csdn.net/wk201403010114/article/details/84067867