Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

If you are looking for PHP HTML script for emails you have come to the right place. If you look at our PHP Snippets for email. You may be disappointed that when you send an email that you do not actually see formatted HTML.

PHP Header For HTML Email

Emails do not automatically display HTML. This is a security measure that implemented years ago. however as more security features advance we safely open HTML emails. You still want to make sure that it is coming from a trusted source before opening the email.

Plain Text Email Code for PHP

If you want to send plain text email to people you would use a code that looks like this. It will not give you a very good looking email. On the other hand a visitor will not get any warnings in their email either. Plain text email are pretty much a thing of the past even if people hate them.
$to = $email;
$subject = 'Service Schedule Confirmation';
$message = 'Hello';
$message .= ' message goes here ';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

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

HTML PHP Email Script

If you want a script that will put HTML in the email use the following code. Notice that we are sending headers with the email. These headers set the mime type. It also declares that the email should use HTML in its content. Finally we use the mail() function in php to do the actual sending of the email.
// Set the content-type to HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// From and CC people
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";

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

Complete Code Example of Sending PHP HTML Emails

If you upload this script to your server you will be able to send an HTML email.
<?php 
if(isset($_POST['submit'])){
$to=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";

mail($to,$subject,$message,$headers);
}
 ?></pre>
<form action="" method="post"><input name="subject" type="text" placeholder="Subject" />
<textarea name="message" placeholder="put message here"></textarea> <input name="submit" type="submit" value="submit" /></form>
<pre>