Adrian Schneider’ Blog: Testing Zend_Mail

When testing an application one not always needs exact replica of production environment. It’s good enough if you can plugin in yourself into specific level of application under test. In his recent post Adrian Schneider looks into using fake mail transport class to catch all e-mails being send and store them in the way testers can access them easily.

Zend has the ability to set a default mail transport class to be used when none is specified, which I’d imagine to be 99% of the time. [...] The alternative (for the 1% who want to manually specify), you’d simply pass an instance of your mail transport object to Zend_Mail::send() when you call it. What should your class contain? It has to extend Zend_Mail_Transport_Abstract, which at this time of writing this, will specifically need to override the abstract _sendMail() method. You can use it to create a new record in your database, create a file, or do whatever you need it to.

Adrian talks about other way of testing e-mail delivery in development/testing environment.