Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

SMTP Stopped Working

Discussion in 'Editor & General Support' started by AdamMoo, Oct 27, 2014.

  1. AdamMoo

    AdamMoo

    Joined:
    Mar 11, 2013
    Posts:
    9
    The following Code which was working previously suddenly stopped working. Anyone have any idea what's causing it or how to fix it ?

    Code (CSharp):
    1. using System.Net;
    2. using System.Net.Mail;
    3. using System.Net.Security;
    4. using System.Security.Cryptography.X509Certificates;
    5. using System.Text.RegularExpressions;
    6.  
    7. public void sendMail (string targetEmail, string subject, string content){
    8.  
    9.      MailMessage mail = new MailMessage();
    10.  
    11.      mail.From = new MailAddress(acEmail);
    12.      mail.To.Add(targetEmail);
    13.      mail.Subject = subject;
    14.      mail.Body = content;
    15.  
    16.      SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
    17.      smtpServer.Port = 587;
    18.      smtpServer.Credentials = new System.Net.NetworkCredential(acEmail, acPW) as ICredentialsByHost;
    19.      smtpServer.EnableSsl = true;
    20.      ServicePointManager.ServerCertificateValidationCallback =
    21.        delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    22.      { return true; };
    23.      smtpServer.Send(mail);
    24.      Debug.Log("Email Sent");
    25. }
    The Error Message shows the following :

     
    OdColmen and sekmano like this.
  2. MCLD3D

    MCLD3D

    Joined:
    Jan 26, 2015
    Posts:
    5
  3. sekmano

    sekmano

    Joined:
    Oct 15, 2017
    Posts:
    3
  4. OdColmen

    OdColmen

    Joined:
    Aug 12, 2018
    Posts:
    3