Hello and thank you for taking the time to look help me with my problem.
I have been working on a small webgl thing within Unity that will send the user an email after t
You cannot use Sockets or any other .Net network class on WebGL. This is for security reasons. Although, you can use Unity's WWW
class.
You still have two Other Options.
[EASY]
1. Re-write the code you have in your question in php. Use Unity WWW
class to send message(toEmail, Subject, Body) to the php script. The php script
will then send the actually email with the information it received from the Unity App.
If you don't want to learn php,you can compile the code in your question as a console app and then use it as cgi instead of php. WWW
class can communicate with both php or cgi programs through GET
or POST
request.
[HARD]
2. You can implement smtp protocol or your own MailMessage
class with UnitySocketIO library. https://github.com/NetEase/UnitySocketIO
Due to security implications, JavaScript code does not have direct access to IP Sockets to implement network connectivity. As a result, the .NET networking classes (ie, everything in the System.Net namespace, particularly System.Net.Sockets) are non-functional in WebGL.
According to unity Doc http://docs.unity3d.com/Manual/webgl-networking.html
Hence the Error.