Page 1 of 1

Send HTML email Using SMTP Authentication

Posted: Fri Nov 14, 2008 8:16 am
by basil_al_dajane
I have the code for sending SMTP authenticated emails
But it only sends plain text email, what should I change in my code to get it to send html emails

Code:

Code: Select all

<?php
require_once "Mail.php";
 
$from = "<name@localhost.com>";
$to = "<recp@otherhost.com>";
$subject = "Subject";
$body = "HTML Body";
 
$host = "localhost";
$username = "name@localhost.com";
$password = "password";
 
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
 
$mail = $smtp->send($to, $headers, $body);
 
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>

Re: Send HTML email Using SMTP Authentication

Posted: Fri Nov 14, 2008 8:43 am
by aaronhall
Googling "php send html email" should return some answers