Should be smarter about headers

sharplesa - February 9, 2009 - 02:05
Project:HTML Mail
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Mass Contact creates the entire email, including headers, which includes Content-Type and Bcc. When htmlmail_mail_alter gets called, all the work that module did gets trashed. The entire header array is totally replaced with a single-element array with the key "Content-Type".

Could the functionality of htmlmail be extended s.t. if the message header already contains a Content-Type that indicates HTML, don't replace it?

Also, could htmlmail preserve all those other important header fields that we had before its mail_alter got called?

How about this logic:
When htmlmail_mail_alter gets called, see if $message is a content type of "multipart*". If it *is*, then see if the body contains a content-type of text/html somewhere in the body. If it *does*, then skip the construction of the header.

On the other hand, if $message does have a header, but that header doesn't already specify a content-type, just *add* the content-type value, don't totally replace everything in the header.

Is this an inherently unsafe approach?

Thanks

#1

mhdg - February 9, 2009 - 22:09

Take a look at the dev version as it should solve your issue !

Enjoy,
Michel

#2

Chris Herberte - February 11, 2009 - 11:55
Status:active» fixed

yep, fixed in dev.

#3

simenro - February 13, 2009 - 20:31

Not fixed in dev for me.

However when I replace the first statement in htmlmail_mail_alter() with this, it works for me:
$message['headers'] = str_replace('text/plain', 'text/html', $message['headers']);

#4

System Message - February 27, 2009 - 20:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.