Hey guys,
I've been looking online for a solution to this but haven't yet found one. I have set up a script to mail an HTML message using SMTP. A message is sent successfully but the HTML is not displayed.
The script:
<?php
require_once "Mail.php";
$from = "xxx";
$to = "xxx";
$subject = "test!";
$message = <<<HTML
<html>
<body bgcolor="#DCEEFC">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br/>
<font color="red">Dance!</font> <br/>
</center>
<br/><br/>*** Now you Can send HTML Email!
</body>
</html>
HTML;
$host = "smtp.gmail.com";
$username = "xxx";
$password = "xxx";
$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, $subject, $message);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
When I compile, I get this message:
Warning: Invalid argument supplied for foreach() in /usr/share/php/Mail.php on line 123
Warning: Invalid argument supplied for foreach() in /usr/share/php/Mail.php on line 151
Message successfully sent!
And the message I get in my inbox is just the displayed html:
<html>
<body bgcolor="#DCEEFC">
<center>
<b>Looool!!! I am reciving HTML email......</b> <br/>
<font color="red">Dance!</font> <br/>
</center>
<br/><br/>*** Now you Can send HTML Email!
</body>
</html>
Why won't this display as HTML? I'm using gmail I don't know if that means anything...As always, thanks for any help you can render!