- Home /
Can the webplayer send emails?
I've searched my question and found no conclusive answers.
I've implemented a c# script that succesfully sends email from the editor and standalone builds, but it relies on libraries that are not avaliable on the webplayer build (System.Net.Mail?).
My implementation follows:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Net;
#if !UNITY_WEBPLAYER
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class MailHelper : MonoBehaviour
{
#region SINGLETON
private static MailHelper _instance;
public static MailHelper Instance
{
get
{
if (!_instance)
_instance = GameObject.FindObjectOfType(typeof(MailHelper)) as MailHelper;
return _instance;
}
}
#endregion
public void sendMailTest()
{
MailMessage tempMail = new MailMessage();
SmtpClient _smtp = new SmtpClient("smtp.gmail.com");
tempMail.From = new MailAddress("[SOME EMAIL ADRESS]");
tempMail.To.Add("[SOME EMAIL ADRESS]");
tempMail.Subject = "subject";
tempMail.Body = "text";
_smtp.Port = 587;
_smtp.Credentials = new System.Net.NetworkCredential("[SOME EMAIL ADRESS]", "[SOME PASSWORD]");
_smtp.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
_smtp.Send(tempMail);
Debug.Log("sent");
}
}
#endif
Can someone point the way to a similar code that works both on standalone and webplayer builds?
Thanks in advance.
Well what you can do for web is to communicate with the website that the unity is running inside of, then there are a multitude of web solutions for this.
However I don't know of any unified theory by hand, good luck! :)
Your answer
Follow this Question
Related Questions
Unity Editor Doesn't Work Anymore 1 Answer
Sprite Editor: Cannot change slice type (Unity 2019.3.15f1 Personal on Linux "Tricia") 0 Answers
Too many errors in the IDE (even for a fresh project), but editor doesn't throw any errors! 1 Answer
Endless loading error 0 Answers
Error: gui window tries to begin rendering while something else has not finished rendering! 0 Answers