I\'m trying to send an email in both text and html, but I can\'t correctly send the right headers. In particular, I\'d like to set the Content-Type header, but I can\'t find how
I discovered that the headers are supposed to be written differently. In particular, some of them are parameters for the mime object, and not email headers. Then the mime_params array should be passed to the get() function.
This is the correct way to set the headers:
$headers = array(
'From' => 'info@mydomain.com',
'Return-Path' => 'info@mydomain.com',
'Subject' => 'mysubject',
'Content-Type' => 'text/html; charset=UTF-8'
);
$mime_params = array(
'text_encoding' => '7bit',
'text_charset' => 'UTF-8',
'html_charset' => 'UTF-8',
'head_charset' => 'UTF-8'
);
$mime = new Mail_mime();
$html = 'my body';
$text = 'my body';
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get($mime_params);
$headers = $mime->headers($headers);
$mail_object =& Mail::factory('smtp', $GLOBALS['pear_mail_config']);
$mail_object->send('test@mydomain.com', $headers, $body);