Nick
Nick

Reputation: 189

cakePHP email is not using my template to send email

When sending email it has the standard message below in the footer.

This email was sent using the CakePHP Framework, http://cakephp.org.

It seems to use this one: /lib/Cake/Console/Templates/skel/View/Layouts/Emails/text

In my controller I have this.

$this->Email->sendAs = 'text';
$this->Email->template = 'dream';

Created the Views:

Is there any other setting I miss to have cakephp using my layout?

*Note: if I rename my dream.ctp to default.ctp it uses that one, so it seems to ignore my template command? How odd.

Upvotes: 0

Views: 3036

Answers (1)

AD7six
AD7six

Reputation: 66299

CakeEmail doesn't have a template property

Based on the paths shown in the question, you're using Cakephp 2. The Cake Email class does not have a template property - which is why manipulating it has no effect.

Refer to the documentation

The documentation includes examples of usage, e.g.:

$Email = new CakeEmail();
$Email->template('dream', 'dreamy')
    ->emailFormat('text')
    ->to('[email protected]')
    ->from('[email protected]')
    ->send();

This will send the dream email using the dreamy layout.

Upvotes: 1

Related Questions