Sunday, 29 September 2013

Email form data to user's email

Email form data to user's email

i am trying to email what the submitter filles out in the textarea to him
after her clicks the "Submit" button. the "current_user" is a wordpress
codex that takes the logged-in user's email.
my code does print out the correct email + what i fill out in the
textarea, but it does not send it to this email. i don't know what to fix.
thanks for your help!
<form action="#" method="post">
<textarea name="lesson1"></textarea><br>
<input type="submit" name="Send" value="Send to your Email" />
</form>
</div>
<?php
global $current_user;
get_currentuserinfo();
$email = $current_user->user_email;
$lesson1 = htmlspecialchars($_POST['lesson1']);
echo $lesson1, $email;
$email_subject = "Test E-Mail (This is the subject of the E-Mail)";
(mail($email, $email_subject, $lesson1);
if(mail($email, $email_subject, $lesson1)){
echo "The email($email_subject) was successfully sent.";
} else {
echo "The email($email_subject) was NOT sent.";
?>

No comments:

Post a Comment