Mohammed Ismail Mohammed Ismail - 10 days ago 7
PHP Question

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error mail

i am totally lost with why i am getting this error at this code:

$finalmessage = "
From:$_POST['name']
Email:$_POST['email']
Message:$_POST['message']
";


Here is the entire mail php code below:

<?php

$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$message = $_POST['message'];
$support_address = "info@bkslegal";
$headers = "From: ".$email;
$header2 = "From: ".$support_address;
$finalmessage = "
From:$_POST['name']
Email:$_POST['email']
Message:$_POST['message']
";

if ( $name == "")

{
}
else
{
mail("$support_address","finalmessage",$headers);
$result = "Your message has been sent succesfully!"

mail("$email","Thank you for contacting us!","We will soon be in contact with you!",$header2);
}
?>

Answer

I see that you wrote your parameters wrong. You wrote:

mail("$support_address","finalmessage",$headers);

It should be:

mail ($support_address, $subject, $message, headers);

and remove this line

//mail("$email","Thank you for contacting us!","We will soon be in contact with you!",$header2);

PHP mail SYNTAX is:

mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
Comments