Recent Posts
- (02/24) Calling an Element from a Helper TAGS:CakephpWeb ProgrammingUsageTutorialExample
- (10/14) Forcing A Single Join in CakePHP PaginationTAGS:CakephpCakephp 13DatabaseErrorsHabtmMysqlMssqlWeb ProgrammingUsage
- (08/11) Inserting NOW() into MySQL Using CakePHPTAGS:CakephpDatabaseMysqlMssqlWeb ProgrammingUsage
- (08/07) Best PaginateCount for CakePHP - with Group By SupportTAGS:CakephpBehaviorsWeb ProgrammingUsageDatabaseExampleMysqlHabtmHack
- (04/03) CakePHP Error Messages Not Showing on FormTAGS:CakephpCakephp 13Web ProgrammingErrorsUsage
- (02/06) Sorting Paginated Results Using a Related Model Field in CakePHPTAGS:CakephpWeb ProgrammingUsageExample
- (11/02) Changing CakePHP's Model useTable on the FlyTAGS:CakephpWeb ProgrammingMysqlDatabaseExampleTutorial
- (10/18) The Funniest Error Message Ever - Thank You EclipseTAGS:EclipseWeb ProgrammingErrorsHumorWindowsUsageSoftwarePhpCakephp
Subscribe to my feed
MainelyDesign.com Blog
Viewing Rendered Email Messages in CakePHP
Posted on 12/09/2009 at 12:15 pm by Kevin Wentworth
Viewed 6,015 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.
Cheers,
-Kevin Wentworth
Tags for Viewing Rendered Email Messages in CakePHP
Cakephp | Component | Example | Usage | Web Programming

Posted by Dr Fox
on 12/12/09
Well done. Although I think the pr() method would be a better option for printing out variables in a neat and readable fashion.