I have the following code for sending mail:
$email_to = 'someone@somewhere.com';
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $name . ' <' . $email_to . '>' . "\r\n" . 'Reply-To: ' . $email;
if(mail($email_to, $subject, $message, $headers)) {
echo 'sent'; // sending this text to the ajax request telling it that the mail is sent..
} else {
echo 'failed'; // ... or this one to tell it that it wasn't sent
}
The mail sends fine but I need to display the phone number along with the message. I’m sure it’s an easy fix and I’ll be all “doh!” when someone schools me, so let’s get it over with! 🙂
You need to append the phone number to the message string.