NowPublic got serious about testing and hired Rok Zlender. Our first project together is email testing. He have mentioned fakemail by the same merry band that has written simpletest. This is a SMTP server which does not deliver anything just writes everything into a file. I began Googling in earnest and after about a quarter hour I realized this does not a full fledged SMTP server -- php.ini has a sendmail_path. This lead to the forthcoming, truly complicated little script:
#!/usr/bin/php <?php $input = file_get_contents('php://stdin'); preg_match('|^To: (.*)|', $input, $matches); $t = tempnam("/tmp/m", $matches); file_put_contents($t, $input);
Name this for example sendmail.php , add it to php.ini as
sendmail_path=/path/to/sendmail.php and create a writeable directory in /tmp called m. Everything sent by php
mail() will land in there.
Commenting on this Story is closed.