Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
- installed html mail version 6.x-2.16
- installed mail system version 6.x-1.11
- 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
- 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
- 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.
- 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. - 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
Comment | File | Size | Author |
---|---|---|---|
#35 | htmlmail_module_php.txt | 6.99 KB | pillarsdotnet |
#15 | htmlmail-htmlmail.tpl_.php_.txt | 779 bytes | pillarsdotnet |
Comments
Comment #1
pillarsdotnet CreditAttribution: pillarsdotnet commentedDid you select HTMLMailSystem in admin/settings/mailsystem ?
Comment #2
TimG1 CreditAttribution: TimG1 commentedI 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
Comment #3
pillarsdotnet CreditAttribution: pillarsdotnet commentedUpdate 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.
Comment #4
pillarsdotnet CreditAttribution: pillarsdotnet commentedBumping version -- 6.x-2.17 has improved debug info in the template file and also in the module settings page.
Comment #5
TimG1 CreditAttribution: TimG1 commentedHmmm,
So, the path in the debug information shows the following:
-Tim
Comment #6
TimG1 CreditAttribution: TimG1 commentedoops, looks like our updates overlapped. Still had the form with 2.16 in it. changing version.
-Tim
Comment #7
pillarsdotnet CreditAttribution: pillarsdotnet commentedIn the template file, the code that produces the output in #5 is:
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.
Comment #8
pillarsdotnet CreditAttribution: pillarsdotnet commentedRelease 6.x-2.18 should detect a non-enabled theme (one that drupal_get_path('theme', $theme) returns an empty string)
Comment #9
TimG1 CreditAttribution: TimG1 commentedHi 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.
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
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
Comment #10
TimG1 CreditAttribution: TimG1 commentedOh, 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
Comment #11
TimG1 CreditAttribution: TimG1 commentedSome new info.
The body of the email sent via the request password form only includes "n/a".
-Tim
Comment #12
pillarsdotnet CreditAttribution: pillarsdotnet commentedYou'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.Comment #13
pillarsdotnet CreditAttribution: pillarsdotnet commented@#11 -- that's an old bug unrelated to HTML Mail. Do you have Mime Mail installed?
Comment #14
TimG1 CreditAttribution: TimG1 commentedHi Bob,
EMAIL DEBUG INFO WHEN NO THEME SELECTED
EMAIL DEBUG INFO WHEN CUSTOM THEME SELECTED
Many thanks,
-Tim
Comment #15
pillarsdotnet CreditAttribution: pillarsdotnet commentedGotcha. Bug in the htmlmail-htmlmail.tpl.php file.
Corrected one attached and fixed in -dev.
Comment #16
pillarsdotnet CreditAttribution: pillarsdotnet commentedComment #17
pillarsdotnet CreditAttribution: pillarsdotnet commentedReleased 6.x-2.20.
Comment #18
pillarsdotnet CreditAttribution: pillarsdotnet commentedComment #19
TimG1 CreditAttribution: TimG1 commentedHi Bob,
Did the following:
<? echo $body; ?>
EMAIL DEBUG INFO WHEN SET TO NO THEME
EMAIL DEBUG INFO WHEN SET TO MY CUSTOM THEME
Many thanks,
-Tim
Comment #20
pillarsdotnet CreditAttribution: pillarsdotnet commentedTim, 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.
Comment #21
pillarsdotnet CreditAttribution: pillarsdotnet commentedWell, I definitely duplicated the problem...
Comment #22
TimG1 CreditAttribution: TimG1 commentedThanks Bob! Let me know when you have a new -dev release ready and I'll be delighted to help you test.
Take care,
-Tim
Comment #23
pillarsdotnet CreditAttribution: pillarsdotnet commentedWell, 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.
Comment #24
pillarsdotnet CreditAttribution: pillarsdotnet commentedTurns out that file_scan_directory() doesn't work like I thought it did. Still troubleshooting...
Comment #25
pillarsdotnet CreditAttribution: pillarsdotnet commentedGot it fixed; just need to remove all my debugging lines and roll another release.
Comment #26
pillarsdotnet CreditAttribution: pillarsdotnet commented6.x is done -- syncing changes with 7.x now.
Comment #27
pillarsdotnet CreditAttribution: pillarsdotnet commentedAll fixed -- testing one more time to be sure before rolling a new release.
Comment #28
pillarsdotnet CreditAttribution: pillarsdotnet commentedFixed in 6.x-2.21 release.
Comment #29
ChrisZZ CreditAttribution: ChrisZZ commentedHi 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
Comment #30
ChrisZZ CreditAttribution: ChrisZZ commentedjust changing status...
Comment #31
pillarsdotnet CreditAttribution: pillarsdotnet commentedOkay, 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.
Comment #32
pillarsdotnet CreditAttribution: pillarsdotnet commentedFixed in 6.x-2.22 release.
Comment #33
pillarsdotnet CreditAttribution: pillarsdotnet commentedVersion bump. 6.x-2.22 has a typo in all the templates.
Comment #34
TimG1 CreditAttribution: TimG1 commentedHi 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
Comment #35
pillarsdotnet CreditAttribution: pillarsdotnet commented@TimG1 -- So let me get this straight:
If that's true, try replacing your
htmlmail.module
file with this one. The only difference is a pair ofwatchdog()
statements added totemplate_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)
Comment #36
TimG1 CreditAttribution: TimG1 commentedHi 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
Comment #37
pillarsdotnet CreditAttribution: pillarsdotnet commentedIn 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 ahtmlmail-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.Comment #39
joep.hendrix CreditAttribution: joep.hendrix commentedafter reading your comment #31, i finally got it working.
I think it is still not documented. In your readme.txt is stated:
That is actually not correct as far as I can tell
Comment #40
kevinquillen CreditAttribution: kevinquillen commentedSo 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.
Comment #41
kevinquillen CreditAttribution: kevinquillen commentedSo, 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.
Comment #42
kevinquillen CreditAttribution: kevinquillen commentedThe only email related modules I have enabled are:
MailEditorI just disabled MailEditor. Looking...
Comment #43
kevinquillen CreditAttribution: kevinquillen commentedSeems like MailEditor conflicts with this. Disabling and uninstalling returned control of the theme to htmlmail.tpl.php. Why are these two not getting along?
Comment #44
labor b CreditAttribution: labor b commentedMaybe 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.
Comment #45
yookoala CreditAttribution: yookoala commented(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.Comment #46
salvisThank you for sharing your research, yookoala.
Is there a way to make this less of a nuisance without breaking existing functionality?
Comment #47
yookoala CreditAttribution: yookoala commented@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:
2. Change these lines in hook_theme:
into these:
Comment #48
salvisComment #49
kenorb CreditAttribution: kenorb commentedD8.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