- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
- (06/12) View Layer - Getting count of Entities in View in Cakephp 3TAGS:CakephpCake3
- (05/23) Changing URL in beforeRedirect() in Component - Cakephp 3TAGS:CakephpCake3Web Programming
- (01/28) Foundation CSS Framework ResourcesTAGS:FoundationCss
- (01/27) Change View File from Controller in CakePHP 3TAGS:CakephpCake3UsageWeb Programming
- (01/13) Loading Model/Table Anywhere in Cake3TAGS:Cake3Cakephp
- (10/06) CURL PHP 5.5 Issue on Windows (Using Twilio SDK)
Subscribe to my feed
Viewing Rendered Email Messages in CakePHP
Posted on 12/09/2009 at 12:15 pm by Kevin Wentworth
Viewed 15,759 times | 1 comment
For a while it's bugged me that I wasn't able to see the rendered output of my email messages that are sent using the CakePHP email component. I would change my code to use a remote smtp server but I still had to send messages. Well, I finally figured out how to "debug" my emails sent using CakePHP. Thanks to this posting for finally putting all the pieces together...
Set $this->Email->delivery to 'debug'
The first step is to tell the CakePHP Email Component to deliver the message using it's debug method. This will tell the Email Component to not send the message, but render it and store the results in a session variable.
- $this->Email->delivery = 'debug';
Access the value of the Email stored in the Session
The next step is to read the value of the Email Message that CakePHP stored in the session variable. This is easy, once you know what it's stored as:
- $this->Email->send(); //make sure you "send" the email before trying to read the session data
Now, it's easy to find out what those email messages will look like without processing the emails through the Internet.