php pear Mail_mime wrong content-type text/html vs multipart/alternative vs multipart/related

206 Views Asked by At

This same code works fine for other emails, just extra attachements. Yet this "same" email code results in an email with Content-Type: text/html... so I can see all the multipart boundries showing in the email or in a multipart/related the html body gets turned into an attachement and the email is blank!

$emailHtml = "<h1>BLAH</h1>"
$emailTxt = "TEXT!"

$mime = new Mail_mime(array('eol'=>"\n"));

$mime->setHTMLBody($emailHtml, false);
$mime->setTxtBody($emailTxt, false);

$mime->headers(array(
  'From' => '"me" <[email protected]>',
  'Subject' => $subject
));
$mail =& Mail::factory('mail');

$mimeparams['text_encoding']="8bit"; 
$mimeparams['text_charset']="UTF-8";
$mimeparams['html_charset']="UTF-8";
$mimeparams['head_charset']="UTF-8";
$mail->send($email, $mime->headers(), $mime->get($mimeparams));
1

There are 1 best solutions below

3
On

Turns out the text portion was blank, which causes Mail_mime to go "insane" for lack of a better description.