I am trying to send an html email. Mail is working properly but not going as html email and it is just displaying ".$message."
. The data is coming from the mysql database.
My script is as follows:
$to = $email;
$subject = $subject;
$message = "$message";
$htmlContent = '
<html>
<body>
".$message."
<br /><br />Regards<br /><b>TM</b>
</body>
</html>';
$headers = 'From: myemail@gmail.com' . "
";
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=UTF-8' . "
";
if(mail($to, $subject, $htmlContent, $headers))
echo "Mail Sent";
else
echo "Problem sending email";
You have mixed single and double quotes. Use only one type when concatenating strings.
$htmlContent = "
<html>
<body>
".$message."
<br /><br />Regards<br /><b>RainbowCTM</b>
</body>
</html>";
To complete previous answer, there is a huge difference between single and double quotes:
echo '$message'
, it just display $message
.echo "$message"
, it displays the content of $message
variable.Finwe is totally right. Explanation: single quotes always take the string as it is without processing variables or metasigns like \t or .
just a hint in addition: try using only and not
since there was a bug in some PHP-version that produced erros. even if this is not a problem at the moment, it might become one after an update (depending on your PHP-version).