Category Archives: PHP-How to Send hmtl mail using PHP function

PHP- How to send E-mail Using PHP mail() function

This tutorial explains about sending email through php mail() function. Before we studied the simple mailing system. Now , this tutorial explains about how to send the email with html format . First, lets introduced with the term


Multipurpose Internet Mail Extensions (MIME) is an Internet standard that extends the format of e-mail to support.MIME defines mechanisms for sending other kinds of information in e-mail

Here is the code sample

$to = “,”;
$subject = “subject to be sent”;

$message = ”
<title>Email including html …</title>
<p>This email contains HTML Tags!</p>

// Always set content-type when sending HTML email
$headers = “MIME-Version: 1.0” . “\r\n”;
$headers .= “Content-type:text/html;charset=iso-8859-1” . “\r\n”;

// More headers
$headers .= ‘From: <>’ . “\r\n”;
$headers .= ‘Cc:’ . “\r\n”;


Sending Email with Attachment

Content-Type: multipart/alternative; boundary=”PHP-alt-

Content-Type: text/plain; charset=”iso-8859-1″
Content-Transfer-Encoding: 7bit

Hello World!!!
This is simple text email message.

Content-Type: text/html; charset=”iso-8859-1″
Content-Transfer-Encoding: 7bit

Hello World!

This is something with HTML formatting.


Content-Type: application/zip; name=””
Content-Transfer-Encoding: base64
Content-Disposition: attachment


Similar Links:
Link 1
Link 2
Link 3