Q:

Is it possible to send cakephp emails from the view

I'm trying to create a pdf and then send it in an email in cakephp.
I can create the pdf ok, and I know how to attach the email but when I create the body of the pdf in a view and then try to send it via email, it doesn't work.
I wonder if the problem is that i can't send emails in a cakephp view. Is it possible?

A:

You shouldn't be doing this in the view, but instead the controller. Create the PDF first, and then set it as an attachment on the email:
https://book.cakephp.org/3.0/en/core-libraries/email.html#sending-attachments

