C# 异常:连接已关闭

C# 异常:连接已关闭,c#,ioexception,unity3d,C#,Ioexception,Unity3d,我正在尝试将163电子邮件发送到unity中的gmail,但出现了一个错误: IOException: Connection closed System.Net.Mail.SmtpClient.Read () System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage me

我正在尝试将163电子邮件发送到unity中的gmail,但出现了一个错误:

IOException: Connection closed
System.Net.Mail.SmtpClient.Read ()
System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message)
System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message)
System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message)
Rethrow as SmtpException: Message could not be sent.
System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message)
sendM.Main () (at Assets/sendM.cs:27)I have
我不知道为什么会这样。我的代码如下所示:

public class mono : MonoBehaviour {
    public string sender = "email@163.com";
    public string receiver = "email@gmail.com";
    public string smtpPassword = "password";
    public string smtpHost = "smtp.163.com";

    // Use this for initialization
    public void Start() {
        using (var mail = new MailMessage {
            From = new MailAddress(sender),
            Subject = "test subject",
            Body = "Hello there!"
        }) {
            mail.To.Add(receiver);

            var smtpServer = new SmtpClient(smtpHost) {
                Port = 25,
                Credentials = (ICredentialsByHost)new NetworkCredential(sender, smtpPassword)
            };
            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            smtpServer.Send(mail);
        }
//  }

这里也是,你找到解决这个问题的办法了吗?@NikaKasradze问题解决了?