Blog

02 Oct
2008

php Elephant Icon Logo

Embedding html in an email with php


Here is the basic code which will allow you to embed html inside an email, with the use of php.

<?php
$from_email = "From: from_email_address\n";
$from_email .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
$subject = "Form confirmation email";
$message = "<html content to go here code>";
$send_to = "to_email_address";
mail($send_to, $subject, $message, $from_email);
?>

Here is another version including other settings such as Bcc, Urgent Message for reference:

<?php
$from_email = "From: from_email_address\n";
$from_email .= "X-Sender: from_email_address\n";
$from_email .= "X-Mailer: PHP\n"; // mailer
$from_email .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$from_email .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
$from_email .= "Bcc:user1@example.com, user2@example.com\n";
$from_email .= "Cc:user1@example.com, user2@example.com\n";
$subject = "Form confirmation email";
$message = "<html content to go here code>";
$send_to = "to_email_address";
mail($send_to, $subject, $message, $from_email);
?>
Tagged: < bcc | cc | email | embed | html | inside email | php >
Posted in: < PHP and HTML and CSS >
me@grafxflow avatar

me@grafxflow


I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!

Visitors also viewed these posts


Add comment

Add comment