[development] HTML emails
Matt Connolly
matt at cabinetuk.com
Wed Jul 16 09:12:33 UTC 2008
I haven't looked at drupal 7 yet, so I'm throwing this out there for
discussion.
The D6 mail api seems like it's pretty much designed for plain text
emails, however, a module's implementation of hook_mail can clearly
set the headers of the mail to "Content-Type: text/html;
charset=utf-8" and send rich text.
For example, I'm looking at using "forward" module for the "email this
page" link on a node, and the "simplenews" module, which uses
"mimemail" to send rich emails, including attachments. Both "forward"
and "mimemail" modules create a html header.
The problem occurs when a module implements "drupal_mail_wrapper()" to
build a html header when hook_mail has already done that - you can
easily end up with bodies like:
<!doctype... <-- from drupal_mail_wrapper()
<html>
<head>...</head>
<body><div....
<!doctype. <-- from hook_mail()
<html>
<head> ... etc.
Because there are two opportunities to create the html "head" for the
message: in hook_mail and drupal_mail_wrapper.
I'm throwing this out there for discussion, I think that the hook_mail
should construct the message in a similar fashion to the Form API,
specifying a theme for rendering the body part of the message (ie what
goes in the <body> tag) and anything special that needs to go in the
head as attributes.
That way the message can be constructed only once.
Besides, email clients have been HTML friendly for a *long* time, so I
don't see why Drupal shouldn't have an interface that understands rich
email messages.
Thoughts?
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080716/4e50b4d2/attachment.htm
More information about the development
mailing list