- Home /
Simple Email Script
hello, community, after some experiments with GUI.TextAreas and GUI.PasswordFields, i've been inspired to make an email form with unity (to send an automatic email to the person by the game itself.)
so the user will enter 3 inputs: email, username, and password.
I plan on having the game send an email (with my email address) with the player's info to their email address.
i've seen some posts on here about smtp stuff. could someone who knows what they're talking about (even a little bit) please explain to me what smtp is, how to use it, and what it does?
or if you could send me a link to a tutorial on scripting involving smtp or email scripting.
(i'm going to do some youtube researching myself, but any help IS appreciated!!!!)
thank you!
I would post the script i have so far, but all it does is make 2 TextAreas and 1 PasswordField and collect that information to PlayerPrefs.
Answer by Keavon · Feb 28, 2011 at 01:33 AM
I would recommend you use PHP, and send a request for a separate PHP page that takes the info in the URL, and then sends it. This is the script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Email Test</title> </head> <body>
<?php
$address = $_GET['address']; $username = $_GET['username']; $password = $_GET['password'];
$content = "Welcome to my game, and thanks for signing up!\nYour login details is as follows:\nUsername: $username \nPassword: $password";
$to = "$address"; $subject = "Thanks for signing up for my game!"; $body = "$content"; $from = "what-ever-email-address-you-want@what-ever-domain-you-want.com"; $headers = "From: $from";
if (mail($to, $subject, $body, $headers)) { echo("<p>Email Sent!</p>"); } else { echo("<p>Email Failed to Send.</p>"); } ?>
</body> </html>
Basically make a new .txt file, open it in WordPad or NotePad, copy that in, edit the message to how you like it (keep in the things with $'s). Edit the email address to select who it's from (note it will always be from your web host, but that is what the users see. It's masked). Then save the file, close your text editing tool, rename the file send_message.php, then upload it to your host (make sure your host is running PHP on their servers).
You want your game to call this url: http://www.example.com/send_message.php?address=user-email@their-host.com&username=user-input-username&password=the-user-input-password
Note you may not want to include their password. You can also star it out, if you want. I hope that helps!
Hehe, and you thought you were young making these things and answering people's questions. 'Bet you didn't think someone even younger than YOU would answer YOUR question. :D Cheers.
Thank you!!! I'll try it out soon. I know how to do some basic HT$$anonymous$$L and JavaScript coding, but not php. But I'm learning from a tutorial (but you really helped me on my way). And answered my question perfectly 100%.
Great! I'm glad I could help! PHP is SO EASY. It's much easier than even JavaScript. :D
wait, so where you said "http://www.example.com/send_message.php?address=user-email@their-host.com&username=user-input-username&password=the-user-input-password " the ww.example.com is my host website?
if so, then perfect! i sorta, kinda get your script. I have an idea of what it's doing. but the syntax and all that,m i'm still learning, anyway, THAN$$anonymous$$ YOU!!!!!
Answer by Eric5h5 · Feb 28, 2011 at 01:27 AM
This isn't anything you'd do in Unity. You send the data to a web app of some kind (write in in PHP, perl, whatever, but it's off-topic here), which does the actual processing and emailing.
Your answer
Follow this Question
Related Questions
How to send a e-mail via smtp 0 Answers
Can't access to gmail using the build 1 Answer
Can the webplayer send emails? 0 Answers
Send an email from unity to email adress? 1 Answer
Serialize data to XML File, then send via email as attachment on iOS. 0 Answers