Allow to define a custom html template
levavie - June 20, 2007 - 07:21
| Project: | HTML Mail |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Thanks for a great work.
I think it's a good idea to try to make the module more modular - Use the standard drupal filters and allow to select which filters to use. This will allow me to add a new RTL filter, to allow right-to-left HTML emails (full spec). It will also allow to write a filter which will automatically add the company logo, or any other custom HTML.
A simpler way to get the same result would be to add a template option, to define the template around the HTML. It's not only HTML and BODY, sometimes it's needed to have a DIV with dir=rtl, or get the company logo on each outgoing email.
To summarize, adding a template field would be great.

#1
Here is my patch - it allows to modify the HTML template body.
It's already working on two of my live sites - I've tested it with GMail, Yahoo Mail, and my local Thunderbird client and the mail looks great. Solves a great problem for me.
Amnon
#2
Amnon, I'm having trouble applying your patch. using patch 2.5.9 what options do you recommend?
#3
make sure the current directory is the htmlmail module directory, then just
patch htmlmail.module < htmlmail.module.patch#4
The patch worked perfectly for version 1.0 as well.
It was a context patch.
Here is a regular diff-style patch:
diff htmlmail.module.orig htmlmail.module<?php>
28,33c28
< $body = "<html>\n" .
< "<head>\n" .
< "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" .
< "</head>\n" .
< "<body>\n" . $body . "</body>\n" .
< "</html>\n";
---
> $body = str_replace ('%body', $body, variable_get('htmlmail_preformat_template',''));
98a94,110
> $default_template =
> "<html>\n" .
> "<head>\n" .
> "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" .
> "</head>\n" .
> "<body>\n %body\n </body>\n" .
> "</html>\n";
>
> $form['htmlmail_settings']['htmlmail_preformat_template'] = array(
> '#type' => 'textarea',
> '#title' => t('Preformatted HTML template'),
> '#default_value' => variable_get('htmlmail_preformat_template', $default_template),
> '#description' => t('The message body to insert as preformatted html.'),
> '#attributes' => array ('style' => 'direction: ltr;'),
> '#rows' => '5'
> );
>
?>
#5
committed prior to 1.0
#6
hey guys
I'm new to drupal. I need to send RTL emails but the problem is that htmlmail is not compatible with D6. so is there new solution which I'm not aware?