concept fakemail in category php

appears as: fakemail
PHP in Action: Objects, Design, Agility

This is an excerpt from Manning's book PHP in Action: Objects, Design, Agility.

In this section, we’ll see how to install fakemail, devise a test with it, and implement the Mailer class accordingly. Then we’ll discuss how the implementation is actually an Adapter on a Zend framework class.

10.3.1. Installing fakemail

So how do we create a fake mail server? As it happens, one of the authors was faced with exactly this task while working on a recent project. The resulting spin-off was the fakemail project on Sourceforge (http://sf.net/projects/fakemail/). Rather than write our own stub, we’ll use this one.

Starting fakemail
Listening on port 25
Figure 10.6. Example of configuring a mail client to use fakemail

We now send a mail as we normally would, as shown in figure 10.7. We then find that fakemail has captured it into a file called someone@somewhere.com.1. If we were to send another mail to the same address, it would be saved as someone@somewhere.com.2. We stop fakemail by hitting Ctrl-C in the terminal. The captured mail should look something like this: