Archive for June, 2007

PHP Pear Mail_Mime HTML message in microsoft outlook

For some reason when you send mails with the Pear extension Mail_Mime with a HTML body, in some outlook clients the e-mail is not displayed correctly. You get a shitty layout, images do not work, you get = signs in your text.
The reason is the some microsoft clients display the quoted-printable encoding in a fucked up way. The solution is easy. Just send the HTML part in base64 encoding. See the following example:

$hdrs = array(
    'From'    => $from,
    'Subject' => $subject
);
$mime = new Mail_mime();
$mime->setTXTBody($text);
$mime->setHTMLBody($html);

$param = array(
    'html_encoding' => 'base64'
);
$body = $mime->get($param);
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');
$mail->send($to, $hdrs, $body);

1 Comment »