I have a CakePHP Shell Script that's sending an email. This script is contained in a CakePHP plugin (foo).
Setting the Email Template as
$this->Email->template = "foo/email_template_name";
Does not work, the email sends successfully, however the email just says
Not Found: /path_to_app/app/views/elements/email/html/foo/email_template_name.ctp
I have verified that the template is named correctly and does exist.
Minor Notes:
$this->Email->sendAs = "both";
If the template is moved to /path_to_app/app/views/elements/email/html/foo/email_template_name.ctp
it does work correctly. However I was hoping to ship this as much as possible as a self contained email including the templates in the plugin itself.
You need to tell CakeEmail the name of the Plugin. (Cake 2.0.x)
In your Model
$email = new CakeEmail();
$email->template('Foo.email_template_name');
or Controller
$this->email->template('Foo.email_template_name');
You need to create the views for the email:
Plugin/Foo/View/Emails/html/email_template_name.ctp
Plugin/Foo/View/Emails/text/email_template_name.ctp
Please post all your code for $this->Email.
Check:
$this->Email->sendAs = 'html';
Have you tried
$this->Email->template = "email_template_name";
and moving the template to
/path_to_app/app/views/elements/email/html/email_template_name.ctp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With