PHP - Is it possible to send HTML mail with php?

Is it possible to send HTML mail with php?

Yes, using the mail() function of PHP, HTML emails can be sent. The content type header must be mentioned.
<?php
// multiple recipients
$to = ‘example@example.com'
// subject
$subject = 'HTML email';

// message
$message = '
<html>
<head>
<title>HTML EMAIL</title>
</head>
<body>
<p>Sample of HTML EMAIL!</p>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Joe <joe@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: HTML EMAIL <sample@example.com>' . "\r\n";
$headers .= 'Cc: samplecc@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>

Is it possible to send HTML mail with php?

Yes, it is possible. The HTML content type to be added to the mail header (as parameter to the function mail() ). The following code snippet depicts the possibility.
mail($recipientAddress, $subject, $messageToSend, From : $senderAddress Content-type text/html; charset = iso-8859-1);
PHP - Explain how to use PGP with PHP
Explain how to use PGP with PHP - In most cases GnUPG(GNU Privacy Guard) is recommended rather than Pretty Good Privacy...
PHP - Explain how to do user authentication in php.
Explain how to do user authentication in php - The most convenient way to authenticate a user in PHP is to use session.....
PHP - Explain how to set the browser timeout.
Explain how to set the browser timeout - Browser time out can be set using set_time_limit() method......
Post your comment