I've got a plugin which am triggering emails from (listening to the users.onSaveUser event).

I am using a conditional to send two emails, depending on the permissions of the person registering the user.

In one instance am using $email->htmlBody = craft()->templates->render('emails/employee', $vars); which works fine.

However, in another instance am using $email->htmlBody = craft()->templates->render('emails/prospect', $vars); and getting the following error:

Unable to find the template “emails/prospect”.

Any ideas why this might be happening or how to get more useful feedback? I have double and triple-checked the spelling of the files and they are indeed available in the file system:

finder screenshot


The template path needs to include your plugin folder name. So in your case the path to your email templates would be pluginname/templates/emails/prospect and the path you pass to render() would be pluginname/emails/prospect.

More info: Plugin template paths explained

But that doesn't explain why the first template path appears to work.

I’d probably keep the templates inside my plugin if they weren’t being used from the front-end. However, if you'd like to change the default template path to your front-end template directory this answer will help.

  • Thanks Luke - have tried with plugin template paths but still getting error Unable to find the template “emails/prospect”. Jun 6 '16 at 14:47
  • Need to use craft()->templates->render( 'pluginname/templatename' ); so plugin name and then leave out your templates directory. I've updated my original answer. Jun 6 '16 at 15:01
  • Thanks Luke! Fixed by updating template path: $path = craft()->path->getSiteTemplatesPath(); craft()->path->setTemplatesPath($path); Jun 6 '16 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.