- Home /
Email not being sent but no specific errors are showing
Here is the thing. I have been trying to send an email with the second method listed here: https://unity3dtuts.com/how-to-send-email-from-unity3d/
I create a MailMessage and SmtpClient classes and populate them exactly how that wonderful post say, and it works! However, when I try the same thing with Siteground mail solution, it doesn't, and the only error I get from the callback is "Message could not be sent."
I have input bad credentials in both Google and Siteground's smtp, and while Google tells me bad credentials where inputted, Siteground always respond with "Message could not be sent."
From scavenging weird Siteground documentation I learned they use SPF and DKIM certifications, but I can't replace current X509 certification with these because (I guess) Unity doesn't include them by default.
So, what should I try next?
public static void SendMail(string to, string subject, string body) { Debug.Log("[Mail] Send mail to: " + to); MailMessage mail = new MailMessage(); mail.From = new MailAddress(MailSenderUser); mail.To.Add(to); mail.Subject = subject; mail.Body = body; SmtpClient smtpClient = new SmtpClient(MailSenderSmtp); smtpClient.Port = MailSenderSmtpPort; smtpClient.Credentials = new NetworkCredential(MailSenderUser, MailSenderPassword) as ICredentialsByHost; smtpClient.EnableSsl = true; smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); try { // ServicePointManager.ServerCertificateValidationCallback = // delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) // { return true; }; // ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; smtpClient.SendAsync(mail, "Mail"); Debug.Log("[Mail] Try send mail async"); } catch (Exception exception) { Debug.LogWarning("[Mail] Exception sending email: " + exception.Message); } } public static void SendCompletedCallback(object sender, AsyncCompletedEventArgs args) { if (args.Error != null) { Debug.Log("[Mail] Error: " + args.Error.Message); } else { Debug.Log("[Mail] Mail Sent!"); } } }
Your answer
Follow this Question
Related Questions
Code signing certificate for Windows and MacOs 0 Answers
Combine 3 Files into a .pfx programatically 0 Answers
Online certification 0 Answers