PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 22, 2022

[FIXED] How to select different layout in Cake PHP Email template

 April 22, 2022     cakephp, cakephp-2.0, cakephp-2.1, cakephp-2.3, php     No comments   

Issue

This is below email code working file

$email = new CakeEmail('smtp');
$fromConfig = EMAIL_FROM_ADDRESS;
$fromNameConfig = EMAIL_FROM_NAME;
$email->from(array( $fromConfig => $fromNameConfig));
$email->sender(array( $fromConfig => $fromNameConfig));
$email->to($this->data['Subscribe']['email']);
$email->subject('Newsletter Confirmation');
$email->template('subscribe');
$email->emailFormat('html');

my above code taking default.ctp layout file by default(app\View\Layouts\Emails\html\default.ctp), it's fine.

But my question is i have created a other fancy.ctp layout file(app\View\Layouts\Emails\html\fancy.ctp) not use default.ctp layout file

How to use this fancy.ctp layout file in Email


Solution

I have solved issue myself......... Below my working code

$email = new CakeEmail('smtp');
$fromConfig = EMAIL_FROM_ADDRESS;
$fromNameConfig = EMAIL_FROM_NAME;
$email->from(array( $fromConfig => $fromNameConfig));
$email->sender(array( $fromConfig => $fromNameConfig));
$email->to($this->data['Subscribe']['email']);
$email->subject('Newsletter Confirmation');
$email->template('subscribe','fancy');
$email->emailFormat('html');


Answered By - thecodedeveloper.com
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing