Send HTML in email via PHP

It is pretty simple. Leave the images on the server and send the PHP + CSS to them…

$to = '[email protected]';

$subject="Website Change Request";

$headers  = "From: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "Reply-To: " . strip_tags($_POST['req-email']) . "\r\n";
$headers .= "CC: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

$message="<p><strong>This is strong text</strong> while this is not.</p>";


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

It is this line that tells the mailer and the recipient that the email contains (hopefully) well-formed HTML that it will need to interpret:

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";

Here is the link I got the information from… (link)

You will need security though…

Leave a Comment