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

MIME:

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

<?php
$to = “receiver1@example.com, receiver@gmail.com”;
$subject = “subject to be sent”;

$message = ”
<html>
<head>
<title>Email including html …</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Roman</td>
<td>BIkesh</td>
</tr>
</table>
</body>
</html>
“;

// 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: <krishna@example.com>’ . “\r\n”;
$headers .= ‘Cc: abc@example.com’ . “\r\n”;

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

Sending Email with Attachment


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

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

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

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

Hello World!

This is something with HTML formatting.

–PHP-alt-

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


–PHP-mixed-

Similar Links:
Link 1
Link 2
Link 3