Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Adrian Schneider' Blog:
Testing Zend_Mail
Feb 15, 2010 @ 17:09:56

In needing to test some mailing functionality in his application Adrian Schneider has come across two ways to handle it on a machine that may not have mail up and configured correctly - mail a mail transport class or sent up a pseudo mail server.

I think a staging environment is more appropriate to actually have email being sent out. Nevertheless, it has made testing any email functionality a little cumbersome. I've done a little research, and have found two ways to tackle the problem. I've also included code samples and other resources to get you started.

The first method - the transport class - uses the Zend_Mail_Transport component (and interfaces) to set the transport for the application and handle the routing from an extension of the Abstract class. The second method involves changes to system settings in the php.ini and adding in a simple script to force a forward to the right address. Windows users can also use fakemail to accomplish a similar thing.

tagged: test zendmail transport phpini fakemail tutorial

Link:

Developer Tutorials Blog:
Testing email routines in web applications
Jul 17, 2008 @ 13:49:16

On the Developer Tutorials blog, there's a recent example of how to validate a common task of many signup forms - if the email sent is actually received.

For any web developer that's ever had to build a signup routine, email is the necessary evil that takes pride of place among hated activities. Sure, a simple call to the language's mail library will send a message through, but the moment the boss wants a HTML email, or users need attachments, everything starts to get tricky.

They try to solve the mail return issue (it tells if the message has gone to the queue, not been delivered) with a little testing and Fakemail. The software looks for emails based on the configuration given and pulls them out to a local directory. Your script can then look here and check the validity of the message before its sent.

This even allows for integration with things like Phing, SimpleTest and Selenium.

tagged: test unittest selenium simpletest phing email fakemail

Link:


Trending Topics: