Cakephp 3.x Email Error: Call to undefined method Cake\Mailer\Email::setFrom()



While sending email, i am getting an error. Here is my code:

use Cake\Mailer\Email;

$email = new Email(‘default’);

$email->setFrom([‘’ => ‘Test Cake Mail’])
->setSubject(‘Test Mail’)
->send(‘Test mail from CakePhp, please checkout.’);

$email object is created as i have debugged but its methods are said undefined.

I also need to debug the mail at local system rather than i send mail to recipients.

Please give some suggestions to debug mail and send properly.



I got that fixed, i looked for Cakephp 3.x documentation and followed code from there. And that version of code wasn’t available at all to the framework version i am using.

I looked into its library and used methods defined there and it worked.

Now, i couldn’t understand how to add another Mail configuration besides default. Any suggestions over this would be great.


  1. As you see, getter and setter are new in 3.4.x and maybe your cakephp version is 3.3.x :grin:

  2. See and