Hi,
I've just made a survey form, and I can't quite figure out how to get the body to come up on the email, does anyone know what I've done wrong?
<?php
require_once "Mail.php";
//send to and whats it called\\
$recipient = '[email protected]';
$subject = ' Completed Survey';
$from = "Mail House <[email protected]>";
$to = "A <[email protected]>";
//Get comments and scores\\
$q1s = $_POST['question1-score'];
$q1c = $_POST['question1-comment'];
$q2s = $_POST['question2-score'];
$q2c = $_POST['question2-comment'];
$q3s = $_POST['question3-score'];
$q3c = $_POST['question3-comment'];
$q4s = $_POST['question4-score'];
$q4c = $_POST['question4-comment'];
$q5s = $_POST['question5-score'];
$q5c = $_POST['question5-comment'];
$q6s = $_POST['question6-score'];
$q6c = $_POST['question6-comment'];
$comment = $_POST['final-comment'];
$email = '[email protected]';
$name = 'Client';
//$email = htmlspecialchars($_POST['email']);
$host = "smtp.host.com";
$username = "x";
$password = "x";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (strstr("\n",$email)){
// $from contains line breaks
die("bad input in the email field");
}
$body = "Name:\t $name \n\n";
$body .= "Question 1: $q1s - $q1c \n\n";
$body .= "Question 2: $q2s - $q2c \n\n";
$body .= "Question 3: $q3s - $q3c \n\n";
$body .= "Question 4: $q4s - $q4c \n\n";
$body .= "Question 5: $q5s - $q5c \n\n";
$body .= "Question 6: $q6s - $q6c \n\n";
$body .= "Final Comment:\t $comment \n";
$headers = "From: $email \n";
if(mail($recipient, $subject, $body, $headers)){
echo(
"<h3 style='color:green;'>Thank you, satisfaction survey successfully sent!</h3><br>Summary of your feedback".
"<ul id='output'>".
"\t<li>Q1: <span>".$q1s."</span> — ".$q1c."</li>".
"\t<li>Q2: <span>".$q2s."</span> — ".$q2c."</li>".
"\t<li>Q3: <span>".$q3s."</span> — ".$q3c."</li>".
"\t<li>Q4: <span>".$q4s."</span> — ".$q4c."</li>".
"\t<li>Q5: <span>".$q5s."</span> — ".$q5c."</li>".
"\t<li>Q6: <span>".$q6s."</span> — ".$q6c."</li>".
"</ul>".
"<p>Final comment: ".$comment."</p>"
);
} else {
echo("<h3 style='color:red;'>Oops, something went wrong <a href='index.php'>try again</a></h3>");
}
?>