I don't seem to get webform-mail.tpl.php to work...

It seems to work when I use two files, a [code]webform-mail.tpl.php[/code] AND a specific [code]webform-mail-%nid.tpl.php[/code] file, and copy both to my theme-folder... But when I only use the [code]webform-mail.tpl.php[/code] file and clear my cache, drupal doesn't seem to use that file...

This is probably related to this issue: #281731: Email theming not working.

#6 webform_mail_pattern.patch1.28 KBquicksketch
Members fund testing for the Drupal project. Drupal Association Learn more


wundo’s picture

Priority: Normal » Critical

We are having the same error here, are we missing something or this is a bug indeed?

quicksketch’s picture

You absolutely have to be using Drupal 6.3 for e-mail theming to work. Theming is completely broken for Webform and Views in 6.2 and earlier.

bforchhammer’s picture

I am using the latest versions of Drupal, Webform and Views!!

platform8’s picture

Me too.. same issue.

mariomaric’s picture

Version: 6.x-2.1.2 » 6.x-2.1.3


I did everything by the book (THEMING.txt), but webform-mail.tpl.php is not working.

I'm using Drupal 6.4 and Webform 6.x-2.1.3.

This is extra useful module and it would be really great to have email theming working.

Tnx in advance.


I did some tests and conclusion is that issue #281731: Email theming not working. is indeed solved, just like pawpetcare wrote:

Now email templates and confirmations work as expected and there's no need to add the original webform-mail.tpl.php and webform-confirmation.tpl.php to the theme folder.

When you have need to add the webform-mail.tpl.php file to theme folder for purpose of theming all webforms, then you fail. Workaround is to edit /sites/all/modules/webform/webform-mail.tpl.php file, which is IMHO not good solution at all.

Another workaround (if you don't want to fork webform module) is to have webform-mail-nid.tpl.php file for every webform (nid) on your site. Which can be really mess if you have more than 5-10 webforms. :(

quicksketch’s picture

Status: Active » Fixed
1.28 KB

Thanks for keeping up with this mariomaric, you identified the remaining problem. Now webform-mail-[nid].tpl.php works fine, but webform-mail.tpl.php does not. Other tpl.php files work fine however.

This was caused by a problem where Webform was using "webform_mail_message" as the theme name, but "webform-mail" as the tpl.php file. This patch fixes this problem by updating the Regular Expression used.

mariomaric’s picture

Just to connect issues: after patching Webform module (6.x-2.1.3) with this patch you need to do some extra work to get webform-mail.tpl.php working as it should! :)

thebenedict’s picture

Status: Fixed » Active

I am having trouble getting e-mail templates to work in 5.x-2.2. I'm not sure if this should be a separate issue.

My Drupal core version is 5.11, and I'm using the Salamander theme. In template.php I have:

function phptemplate_webform_mail_message_324($form_values, $node, $sid, $cid) {
  return _phptemplate_callback('webform-mail-324', array('form_values' => $form_values, 'node' => $node, 'sid' => $sid, 'cid' => $cid));

and an email template is in webform-mail-324.tpl.php.

Are hyphens and dashes in the right place? Is there a more recent dev version I can try? (I don't see it on the module page) I've tried making a file named webform-mail.tpl.php in my theme directory but that has no effect.

Thanks for any help or suggestions.

thebenedict’s picture

Status: Active » Fixed

It turns out I'd made a typo (not in the code above) that was causing this. It's working well now. Sorry folks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

ss81’s picture

Issue isn't closed! I have it too.. Seems like I have a decision..

Copy from the manual:
"- Copy the "webform-form.tpl.php" file from the webform directory to your theme directory. You may rename this file"

1. You have to move file to the theme folder, not copy.
2. If you want to use only webform-form.tpl.php file -- you can make changes only in it. It you want to create separate files to each form -- you must to leave webform-form.tpl.php file in your theme folder and you can create "webform-form-[node id here].tpl.php" files.

As I found out, if you still have the theme files in webform folder -- you will have an issue.. as I think you have to delete these files for 6.x version. This way helps to me.

sankar_jeya’s picture

Title: webform-mail.tpl.php not working » webform-form-[node id] not working

i used custom node tpl in module folder + theme folder this not working .. plz will u provide any solution

kurosevic’s picture

I've just got this stupid thing working after fiddling with it all day long. =D

OK. so there was two things I was definitely doing incorrectly, and the moment I stopped doing them, it magically began to work. So, hopefully my solution works for you as well... but pay close attention to the order in which these things happen... it seemed to make a lot of difference in solving my problem =D

1. First, I deleted any of the override webform-mail-[nid].tpl.php files you've created in the modules/webform folder; they appeared to confuse the module.
2. create an override file in themes/your-theme-folder as webform-mail-[nid].tpl.php.
---- here's one thing thats sortof important to remember: nid is not the same as form_id, so don't try anything funny like naming your file webform-mail-webform_client_165.tpl.php. You should only have a number... the NID.
Question: Whats my node id? where do i find it? well... lets say that before you turn on your fancy urls, you'd see something like website.com/?q=165. Look at your url for a number. Thats the one.
3. because you now have a file that was not in the theme a moment ago, you need to rebuild theme registry by clearing file cache. Go to yoursite.com/admin/settings/performance and scroll to the bottom and clear the cache.
4. go back to your form, and refresh it. then type some stuff in the fields and submit it.
5. the email should be the correct one. <-- thats all i did to get it working.

note: once the proper override file is being referenced, you don't need to clear your caches each time you save an update to the file... you just save the file and run the form again...

rsacchi’s picture

Version: 6.x-2.1.3 » 6.x-2.9
Component: Code » Miscellaneous
Category: bug » support

Thanks kurosevic for the explanation, it worked like a charm.


Roger Luiz Tottene’s picture

Assigned: Unassigned » Roger Luiz Tottene

Basta colar o webform-mail.tpl.php + webform-mail-[nid].tpl.php na pasta do seu tema que tudo vai funcionar corretamente!


Isso também vale para outros modulos como views etc...


Scott M. Sanders’s picture

If yours does not show up as the default template, and you did it correctly, yours will still be what emails.

I think this should be fixed though so as not to confuse.