aweklin
06-21-2012, 11:23 AM
Hello guys,
I want to be able to send mail in html format like the one below but I get the raw html in my mail.
include_once "Mail.php";
function isMailSent($from, $to, $subject, $body) {
$host = "mail.domain.com";
$username = "email@domain.com";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
try {
// add to the body
$body = '<p><img src="/images/logo.png" /></p>' . $body . '<p>Thank you!</p>';
// dispathc mail
$mail = $smtp->send($to, $headers, $body);
// check if mail was sent successfully
if (PEAR::isError($mail)) {
return "<p>" . $mail->getMessage() . "</p>";
} else {
return "<p>Message successfully sent!</p>";
}
} catch (Exception $e) {
return $e->getMessage();
}
}
Please help.
I want to be able to send mail in html format like the one below but I get the raw html in my mail.
include_once "Mail.php";
function isMailSent($from, $to, $subject, $body) {
$host = "mail.domain.com";
$username = "email@domain.com";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
try {
// add to the body
$body = '<p><img src="/images/logo.png" /></p>' . $body . '<p>Thank you!</p>';
// dispathc mail
$mail = $smtp->send($to, $headers, $body);
// check if mail was sent successfully
if (PEAR::isError($mail)) {
return "<p>" . $mail->getMessage() . "</p>";
} else {
return "<p>Message successfully sent!</p>";
}
} catch (Exception $e) {
return $e->getMessage();
}
}
Please help.