In line 20 of the code, hook_mail_alter is replacing then entire $message['headers'] variable with the content type:
$message['headers'] = array(
'Content-Type' => 'text/html; charset=UTF-8;',
);
Any previously assigned headers are now lost, especially the "from:" address specified by the sixth argument of the drupal_mail function. I'm not sure if that's by design, but would simply redifining the "Content-Type" key of the $message['headers'] array do the same trick? For example:
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
That way other headers are still left intact.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | htmlmail-382950.patch | 739 bytes | jrglasgow |
| #7 | htmlmail.patch | 521 bytes | jax |
Comments
Comment #1
Christopher Herberte commentedCommitted to HEAD, thanks ttrinidad.
Please test.
Comment #2
timtrinidad commentedWorks for my setup! Thanks, Chris.
Tim
Comment #4
timtrinidad commentedIt seems as if this commit was overwritten by an older version and is no longer in the latest release (official or dev).
Comment #5
jguffey commentedYeah, would be nice if you updated, this was a pain in the arse to find. :(
Comment #6
Anonymous (not verified) commentedStill a problem in the release.
Comment #7
jax commentedHere's a patch.
Comment #8
piccola commentedBecause Mime mail module still does not work for drupal 6, in the simplenews module we had to use HTML mail module. This patch solved the problem of "from:" address being changed into something like mydomain@box...bluehost.com. By the way, simplenews needed also a patch to be able to use the htlm module. See http://drupal.org/node/367488
Thanks a lot.
Piccola
Comment #9
adshill commentedThis still seems to cause problems with the mail envelope coming from the server address rather than that specified - so many mail servers decline the messages. Is there anything I can do to solve this?
Thanks,
Adam
Comment #10
jrglasgow commentedhere is a patch that has been re-rolled from the current dev version
Comment #11
jwilson3I'd like to propose a change here that doesn't override the Content-Type header if it already exists. Other modules have the opportunity to create the Content-Type message header to match the actual message body, and, lets say, the module needed to change the charset aspect of the Content-Type header. Well, this module, as is even with the patches above, might conflict with some other modules' previously-specified Content-Type header, and there still exists the possibility that this module overrides it, causing problems lets say in the case of charset.
All this module really needs to do is ensure that someone has set the type to 'text/html', they don't care about charset. So I propose a solution like the following:
If the Content-Type header exists and already has 'text/html' then do nothing, otherwise add in the default value (text/html; charset=UTF-8;)
Circa line 20, htmlmail.module
And further below... use the Content-Type value in the header array for the "HEAD" section of the message body...
Circa line 30, htmlmail.module
I also vote that if not my suggestions, at least the above patches get rolled into a NEW RELEASE PLEASE. This seems to have affecting enough people (myself included) and has cause various people to have to track down the problem and fix it, such that a simple 6.x-1.1 release would be worthwhile. thanks!
Comment #12
Christopher Herberte commented#11 jrguitar21, commited Circa line 20 header fix as per this comment. -- To 6.x dev and HEAD
Circa line 30, this is probably the 5.x code as theme function was added some time ago to 6.x
Although this is a good way to attack we're only theming the body a this time. this will be considered for a future release.
Comment #13
Christopher Herberte commented