Hi I think I'm doing this right, but html mail doesn't seem to be picking up my htmlmail.tpl.php template file. Here is what I did:

  1. installed html mail version 6.x-2.16
  2. installed mail system version 6.x-1.11
  3. I copied the default htmlmail.tpl.php page from http://drupalcode.org/project/htmlmail.git/blob_plain/refs/heads/6.x-2.x... and placed in my theme folder
  4. On "step 2" on this page admin/settings/htmlmail/settings I chose my theme folder from the dropdown menu that my htmlmail.tpl.php file is located in
  5. On "step 3" on this page admin/settings/htmlmail/settings I chose my new "HTML Email" filter which includes emogrifier, html filter, line break converter, and url filter.
  6. I put the words "hello" right before <?php echo $body; ?> in the htmlmail.tpl.php file in my theme folder to see if that shows up in the test email and it does not show up.
  7. I tried clearing my cache multiple times and tried running cron multiple times and still no "hello" in my emails

Am I doing something wrong?

Many thanks for reading,
-Tim

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pillarsdotnet’s picture

Status: Active » Postponed (maintainer needs more info)

Did you select HTMLMailSystem in admin/settings/mailsystem ?

TimG1’s picture

I did not have HTMLMailSystem selected!

But I just selected HTMLMailSystem in admin/settings/mailsystem, cleared cache twice, ran cron twice, but still no "hello" in my test emails. =/

Something else probably worth noting, my site is using Aegir.

-Tim

pillarsdotnet’s picture

Update to 6.x-2.17 (just released) and check the debug checkbox and send another test mail.

The debug info should include your theme path. See if it is correct.

pillarsdotnet’s picture

Version: 6.x-2.16 » 6.x-2.17

Bumping version -- 6.x-2.17 has improved debug info in the template file and also in the module settings page.

TimG1’s picture

Version: 6.x-2.17 » 6.x-2.16

Hmmm,

So, the path in the debug information shows the following:

Copy htmlmail--htmlmail.tpl.php to the sites/all/modules/htmlmail directory of your Alhambra theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

-Tim

TimG1’s picture

Version: 6.x-2.16 » 6.x-2.17

oops, looks like our updates overlapped. Still had the form with 2.16 in it. changing version.

-Tim

pillarsdotnet’s picture

In the template file, the code that produces the output in #5 is:

Copy the
<a href="http://drupalcode.org/project/htmlmail.git/blob/refs/heads/6.x-2.x:/html..."><code>html.tpl.php</code></a>
file to the
<u><code><?php echo realpath(drupal_get_path('theme', $theme)); ?></code></u>
directory of your <u><?php echo ucfirst($theme) ?></u> theme.

So then, drupal_get_path('theme', 'alhambra') is returning 'sites/all/modules/htmlmail'?

Either your drupal is very broken or you aren't really using the template that you linked to above.

EDIT: I figured it out.

Your "alhambra" theme isn't enabled.

So drupal_get_path('theme', 'alhambra') is returning NULL or a blank string.

And realpath('') returns the current directory.

Okay, I will work on better debug info in a future version.

Thanks for the feedback.

Meanwhile, you need to enable your theme.

pillarsdotnet’s picture

Version: 6.x-2.17 » 6.x-2.18
Status: Postponed (maintainer needs more info) » Fixed

Release 6.x-2.18 should detect a non-enabled theme (one that drupal_get_path('theme', $theme) returns an empty string)

TimG1’s picture

Status: Fixed » Active

Hi Bob,

My theme is enabled and always has been. HTML Mail was working fine pre-upgrade until Mail System was required in the new upgrade.

It's still not picking up the htmlmail.tpl.php. I upgraded to 6.x-2.18 and the debug info in the test email shows the following.

Copy htmlmail--htmlmail.tpl.php to the sites/all/modules/htmlmail directory of your Alhambra theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

I don't see a file titled htmlmail--htmlmail.tpl.php (two dashes) in the module folder. I do see htmlmail-htmlmail.tpl.php (one dash) though. Should I be copying the code from this file instead of the htmlmail.tpl.php file?

Also, I'm not sure what the debug info means when it says

Copy htmlmail--htmlmail.tpl.php to the sites/all/modules/htmlmail directory of your Alhambra theme.

You're not saying I should have a directory called sites/all/themes/custom/alhambra/sites/all/modules/htmlmail/htmlmail.tpl.php are you? To me that's what the debug info is telling me to do, but that doesn't sound right. I'm sure I'm misunderstanding it.

Many thanks for the help!
-Tim

TimG1’s picture

Oh, and the path in the debug info actually longer. It's the full path to the sites/all/modules/htmlmail directory on the server. I just removed the first part of the path for posting here. I can PM you the full path if it will help with debugging. I'd just rather not post it here. =)

Thanks again,
-Tim

TimG1’s picture

Some new info.

The body of the email sent via the request password form only includes "n/a".

-Tim

pillarsdotnet’s picture

Version: 6.x-2.18 » 6.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

You're still using the old template file. Please search through your drupal installation for htmlmail-*.tpl.php files. The output that you are quoting above could not have come from the 6.x-2.18 version.

pillarsdotnet’s picture

@#11 -- that's an old bug unrelated to HTML Mail. Do you have Mime Mail installed?

TimG1’s picture

Hi Bob,

  • @#13 -- I did have Mime Mail installed, but it was not enabled. I just tried uninstalling and removing the module from my modules directory and then tried the things below.
  • I searched through the installation and didn't see any html-*.tpl.php files.
  • I uninstalled mail system + html mail then removed them from my modules folder
  • I deleted any old html-*.tpl.php from my custom theme folder
  • Cleared cache, ran cron, ran updates, twice.
  • I downloaded and installed mail system + html mail and reconfigured again. Making sure to set Mail System settings to HTML mail in the dropdown.
  • Cleared cache, ran cron, ran updates, twice.
  • I tried sending test emails with debug turned on with "No Theme" set on admin/settings/htmlmail/settings and then with my custom theme selected after placing a copy of htmlmail.tpl.php with "hello" inside my custom theme folder. The results of those emails are below.
  • Emails from request password still show n/a

EMAIL DEBUG INFO WHEN NO THEME SELECTED

customize this test message:
Copy htmlmail--htmlmail.tpl.php to the sites/all/modules/htmlmail directory of your theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

EMAIL DEBUG INFO WHEN CUSTOM THEME SELECTED

To customize this test message:
Copy htmlmail--htmlmail.tpl.php to the sites/all/modules/htmlmail directory of your Alhambra theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

Many thanks,
-Tim

pillarsdotnet’s picture

Gotcha. Bug in the htmlmail-htmlmail.tpl.php file.

diff --git a/htmlmail-htmlmail.tpl.php b/htmlmail-htmlmail.tpl.php
index d2b64f1..56ebea4 100644
--- a/htmlmail-htmlmail.tpl.php
+++ b/htmlmail-htmlmail.tpl.php
@@ -16,8 +16,8 @@
     To customize this test message:
   </p></dt><dd><ol><li><p>
     Copy
-    <a href="http://drupalcode.org/project/htmlmail.git/blob/refs/heads/6.x-2.x:/htmlmail-htmlmail
-    to the <u><code><?php echo realpath($directory); ?></code></u>
+    <a href="http://drupalcode.org/project/htmlmail.git/blob/refs/heads/6.x-2.x:/htmlmail-htmlmail
+    to the <u><code><?php echo $theme_path; ?></code></u>
     directory of your <q><?php echo ucfirst($theme) ?> theme</q>.
   </p></li></ul></p></li><li><p>
     Edit your copy of the <u><code>htmlmail-htmlmail.tpl.php</code></u> file.

Corrected one attached and fixed in -dev.

pillarsdotnet’s picture

Status: Postponed (maintainer needs more info) » Needs work
pillarsdotnet’s picture

Released 6.x-2.20.

pillarsdotnet’s picture

Status: Needs work » Postponed (maintainer needs more info)
TimG1’s picture

Version: 6.x-2.x-dev » 6.x-2.20
Status: Postponed (maintainer needs more info) » Active

Hi Bob,

Did the following:

  1. upgraded to v 6.x-2.20
  2. ran updates, cleared cache, & ran cron
  3. Copied htmlmail-htmlmail.tpl.php AND htmlmail.tpl.php to my custom theme directory and added "Hello" below the <? echo $body; ?>
  4. did a test email with step 2 on this page set to no theme. admin/settings/htmlmail/settings email debug info below.
  5. Tried requesting a new password, and the email came through okay.
  6. Changed step 2 on this page to my custom theme. admin/settings/htmlmail/settings email debug info below. No "Hello" appearing in email.
  7. Tried requesting a new password, "n/a" still coming through instead of new password email.

EMAIL DEBUG INFO WHEN SET TO NO THEME

To customize this test message:
Copy htmlmail-htmlmail.tpl.php to the directory of your theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

EMAIL DEBUG INFO WHEN SET TO MY CUSTOM THEME

To customize this test message:
Copy htmlmail-htmlmail.tpl.php to the sites/mysite.com/themes/custom/alhambra directory of your Alhambra theme.

Edit your copy of the htmlmail-htmlmail.tpl.php file.

Many thanks,
-Tim

pillarsdotnet’s picture

Tim, thank you very much for your patience in this matter. I am going to install a local copy of a custom theme and test accordingly.

pillarsdotnet’s picture

Status: Active » Needs work

Well, I definitely duplicated the problem...

TimG1’s picture

Thanks Bob! Let me know when you have a new -dev release ready and I'll be delighted to help you test.

Take care,
-Tim

pillarsdotnet’s picture

Well, I figured out half the problem.

The change I made to the 7.x-2.x branch that auto-detects template files somehow got dropped when I updated the 6.x-2.x branch.

I've fixed that bit but I'm still getting a blank email body just like you reported.

So... Still needs work.

pillarsdotnet’s picture

Turns out that file_scan_directory() doesn't work like I thought it did. Still troubleshooting...

pillarsdotnet’s picture

Got it fixed; just need to remove all my debugging lines and roll another release.

pillarsdotnet’s picture

6.x is done -- syncing changes with 7.x now.

pillarsdotnet’s picture

All fixed -- testing one more time to be sure before rolling a new release.

pillarsdotnet’s picture

Version: 6.x-2.20 » 6.x-2.21
Status: Needs work » Fixed
ChrisZZ’s picture

Hi All,

i encounter a similar problem: htmlmail-simplenews.tpl.php is only picked up from the module directory, not the theme directory. I just upgraded to 2.21, same results. Theme is activated!

The Debug information provides for the right directory / and i followed those instructions. Put i can only achieve the required result by copying the template into the module directory..

1. For general Simplenews message customization, copy
sites/URL/modules/htmlmail/htmlmail-simplenews.tpl.php

to
sites/URL/themes/saledn/htmlmail-simplenews.tpl.php

I am running AEGIR as well...

Thanks for this wonderful initiative! This module really helped us a lot already!

regards
Christian

ChrisZZ’s picture

Status: Fixed » Needs work

just changing status...

pillarsdotnet’s picture

Status: Needs work » Active

Okay, you have to copy both htmlmail.tpl.php and htmlmail-simplenews.tpl.php to the theme directory.

I'll roll a new release shortly that documents that little gotcha.

pillarsdotnet’s picture

Version: 6.x-2.21 » 6.x-2.22
Assigned: Unassigned » pillarsdotnet
Category: support » bug
Status: Active » Fixed
pillarsdotnet’s picture

Version: 6.x-2.22 » 6.x-2.23

Version bump. 6.x-2.22 has a typo in all the templates.

TimG1’s picture

Status: Fixed » Active

Hi Bob,

Sorry I upgraded to 6.x-2.23 and I'm still experiencing the same thing....

Password request emails say "n/a" and test email is not being read.

Did all the usual stuff, clear cache, make sure Mail System settings are set, etc.

Were you able to get it working on your clean installation?

@#29 Chris Zange, were you able to get version 6.x-2.23 working on your install?

EDIT
Also upgraded Mail System to 6.x-1.13 and am still experiencing same behavior.

-Tim

pillarsdotnet’s picture

Status: Active » Postponed (maintainer needs more info)
FileSize
6.99 KB

@TimG1 -- So let me get this straight:

  • You are getting the debugging info included in your test mails.
  • You are not getting any message body included in your test mails.

If that's true, try replacing your htmlmail.module file with this one. The only difference is a pair of watchdog() statements added to template_preprocess_htmlmail().

Send your test messages again, then look at your admin/reports/dblog Log entries.

If you see anything of Type "htmlmail" please post it somewhere I can find it. Cut-and-paste; no screenshots, please.

Thanks.

Bob Vincent (a.k.a. pillarsdotnet)

TimG1’s picture

Status: Postponed (maintainer needs more info) » Active

Hi Bob,

I'm getting different behavior than yesterday. I must have still has something cached yesterday. Here is what I am seeing now.

TEST EMAIL
This is working! Woot! When I send a test email I see my "hello" that I put in the htmlmail-htmlmail.tpl.php file that is in my custom theme directory.

REQUEST PASSWORD EMAIL
When I go to the request password page and request a new password, the email comes through fine no more "n/a". But I don't see the "hello" that I put in the htmlmail.tpl.php file in my custom theme directory.

Do you still need the watchdog info from the test email now that it's working okay? If so, let me know and I'll message it to you.

Many thanks,
-Tim

pillarsdotnet’s picture

Status: Active » Fixed

In the new version I have added a sample template file called htmlmail-user-password-reset.tpl.php. You need to copy that file to your theme directory, or create another template file with the same name. If you don't have a htmlmail-user-password-reset.tpl.php file in your custom theme directory, the one in the htmlmail module directory will be used.

I'm calling this issue fixed; please re-open if you still have problems. Remember to clear cache every time you create, copy, or rename a .tpl.php file.

Status: Fixed » Closed (fixed)

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

joep.hendrix’s picture

after reading your comment #31, i finally got it working.
I think it is still not documented. In your readme.txt is stated:

 * the possible template file names would be:
 *  1. htmlmail-example-module-outgoing-message.tpl.php
 *  2. htmlmail-example-module.tpl.php
 *  3. htmlmail.tpl.php

That is actually not correct as far as I can tell

kevinquillen’s picture

Version: 6.x-2.23 » 7.x-2.65

So wait, can you not just copy htmlmail.tpl.php to your theme and use it that way? You have to specify all the $module names in the filename? The readme says you can use htmlmail.tpl.php but I can't get it to use it. It will only use htmlmail--htmlmail.tpl.php for test emails, --webform for Webform, etc. I'd have to duplicate that TPL for every module using hook_mail and I don't want to have to do that.

I have everything configured as per the Readme. The test email will ONLY render the email with htmlmail--htmlmail.tpl.php- but it should be using htmlmail.tpl.php, renaming it makes it use the default in the htmlmail module folder.

kevinquillen’s picture

Status: Closed (fixed) » Active

So, we've followed the instructions pretty thoroughly and put html.tpl.php inside our active theme and configured the modules to the way they should be to use HTML formatted emails and the email theme.

However htmlmail.tpl.php is not being used whatsoever, and the debugging information is suggesting to use -$key instead of the default template.

This is how we did it on a D6 site that worked perfectly. Having issue with Drupal 7.

kevinquillen’s picture

The only email related modules I have enabled are:

  • Html Mail
  • Mailsystem
  • Emogrifier
  • Pathologic
  • MailEditor

I just disabled MailEditor. Looking...

kevinquillen’s picture

Seems like MailEditor conflicts with this. Disabling and uninstalling returned control of the theme to htmlmail.tpl.php. Why are these two not getting along?

labor b’s picture

Maybe this is helpful. To get this to work I deleted all .tpl.php files from the module directory except htmlmail.tpl.php.

Afterwards the mail templates where grabbed from the theme.

yookoala’s picture

(answer about Drupal 7 problem)

You cannot override the template in normal way. In addition to creating the template in your theme, you have to select the theme in htmlmail configurations.

htmlmail has hard-wired "theme path" of all its templates in hook_theme. It requires you to select your email theme in htmlmail settings. If you don't select any theme, and by default, it will ONLY use the template file in the module folder.

salvis’s picture

Thank you for sharing your research, yookoala.

Is there a way to make this less of a nuisance without breaking existing functionality?

yookoala’s picture

@salvis

htmlmail is overriding "theme path" variable in hook_theme() with `htmlmail_get_selected_theme()` result even when no theme is selected.

I did not have time to test, but I think a possible solution is to:

1. Remove these lines in hook_theme:

  else {
    $theme_path = $module_path;
  }

2. Change these lines in hook_theme:

    $items[$suggestion] = array(
      'variables' => array('message' => array()),
      'template' => $template,
      'path' => $path,
      'theme path' => $theme_path,
    );

into these:

    $items[$suggestion] = array(
      'variables' => array('message' => array()),
      'template' => $template,
      'path' => $path,
    );
    if (isset($theme_path)) $items[$suggestion]['theme path'] = $theme_path;
salvis’s picture

Status: Active » Closed (outdated)
kenorb’s picture

D8.x, for the reference:

1. Copy ./modules/contrib/htmlmail/templates/htmlmail.html.twig into themes/custom/YOURTHEME/templates/htmlmail--htmlmail.html.twig
2. drush twigc
3. drush cr