Hey guys! I’ve asked this question in the old forums but this time I’ll try to be more specific.
In the original document I tried to send mail from a local machine (at a museum with internet connection) that will send the results of a quiz that the user has been playing to his/her own email adress. What you get once the quiz is done is a result screen and a function which allows you to type in your email adress and click on a submit/send button.
However, since I have no idea on how php works I’m curious to see if anyone has done this and could give me some advice.
I have been trying the phpmailer on github. I copy pasted the example code from the readme and ended up in two php-files. I also tried to follow the instructions at this link which has a preset of the guys’ email, but when I export the hype document and open up the html-file and click submit I get the php file in a text version instead of a “wrong email adress” or w/e.
If anyone of you gently souls could spare a minute or two and explain what I need to do to get it working would be very much appreciated!
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = $email; // who to send it too
$from = "email@example.com";
$subject = $subject;
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $from\n";
//options to send to cc+bcc
//$headers .= "Cc: [email]firstname.lastname@example.orgXom[/email]";
//$headers .= "Bcc: [email]email@example.comXom[/email]";
// now lets send the email.
echo mail($to, $subject, $message, $headers);
Now, you just need an ajax request from within Hype to send the info collected in the above `$_POST’ statement.
Awesome MrAddy! Will look into it and see if I can make it work. Just a quick question: How do I do to add my gmail account so that all the mails that you are sending will be sent from it, or did you mean that I keep all the attached php files in the document and add another (third) php file?
How it should work:
Person has finished the quiz
Person is typing his email adress
Person is clicking on submit
An email has been sent from my email (gmail) to his/her with an attached .png file
Well the thing is that I don’t have a “server”, it’s all being run from the desktop where I have a folder which includes the html and resources. So, to get the email function working I should need a password and smtp-info right? That’s why I was wondering if I only needed your code and not anything else.
I’m probably asking for too much Addy but is it possible for you to add the working code to the hype project that I linked in the first comment?
Wow, thanks Andrew!
It worked perfect from the website that you were hosting it on! However, I’m not sure how to set up a local server. I had no clue until you told me that I needed it, should be obvious I guess since it’s php (which I’m not used to work with though… excuses ).
I managed to install XAMPP on my mac computer and added the files to the correct path which is under “htdocs”. I’ve tried some phpinfo and hello codes and they are working as they should do. I’m not sure why your example isn’t. I’m not getting a result in the resultbox. Maybe that’s a clue?
Sorry but I’m not sure if I can do that since it’s not hosted on any domain.
[context: document, selector: “#email”, jquery: “2.1.3”, constructor: function, toArray: function…]
If you are running a server, it will tell you the IP of the server, if the server is connected to a router, you will get an internal IP, like, 192.168... From within the route, you can port forward :8080 to the servers local address. Then the IP on your router you just provide, and we, on the outside, just need to put that ip, with port 8080, example
This is the best way, and I cannot see why this would not work. That said, what is on the post tab ?
Hi again MrAddy and nick! Thank you so much for your help! I managed to create a server that is working on a PC using the link you provided me nick (WAMP in this case)! Also, I managed to send an email with phpMailer so the send email is working as it should.
Today I have been trying to implement the new php-code into your hype project MrAddy, as well as adding a virtual keyboard for the touch monitor that will display the site.
Since I am quite unsure on how php is coded I am in need of your help again. What I need is the “send-email.php” file to collect the information from the #emailbox just like yours did. I’ve been trying many ways but I can’t find out how to do it, but I guess it has to do with the $email that has been replaced with $mail.
A little note: I will also be in need to collect data from an image in the scene, just like how the $subject works. Any idea on this one?
Hi Daniel! As soon as I get this working correctly I will post a tutorial on how I solved it.
The problem right now is that I need to collect the data from the text input inside hype and change the addAddress in my send-email.php to the email that has been typed inside the text input. I have no idea how to do this
UPDATE::: I fixed it! Borrowed some of Andrews code and implemented it in the new php file that I created. Thanks for all the awesome help! Will get back this weekend/next week and make a tutorial for anyone else who’s having trouble getting it up and running!