Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Dunn
6,623 Points"Unknown sender" when sending emails with php
So I want users to be able to send emails through a contact form that I created. The problem is that whenever a user sends an email, I receive an empty email with the users email not included. So If a user sends me an email, I don't know who it is from because the user's email is not included. I also don't know what has been said because the message part is empty as well. All I can see is "New Message", which is the title of the email. Does someone have an idea why the user's email and the message is empty?
<?php
$userEmail = $_POST['userEmail'];
$userMessage = $_POST['userMessage'];
$to = "testemail@email.com";
$subject = "New Message";
$headers = "From: " . $userEmail;
mail ($to, $subject, $userMessage, $headers);
echo "Thanks for you message! I will get back to you shortly."
?>
Thanks!