Installation

Get the source

Extract or git pull the sources below your webroot, eg. in subfolder ./vendor/emailcatcher/

cd [WEBROOT]
cd vendor
git clone https://git-repo.iml.unibe.ch/iml-open-source/php-emailcatcher.git emailcatcher

Enable fetching emails

In the php.ini in section [PHP] add a value for sendmail_path:

[PHP]
...
sendmail_path = "[WEBROOT]/vendor/emailcatcher/php-sendmail.php"

Test sending an email

If you have no php script that sends an email you can create a test file like this:

<?php
$sTO="somebody@example.com";
$sSUBJECT="My subject - ".date("Y-m-d H:i:s");
$sBODY="Hello you,

I am just testing to fetch the email...
";

$ret = mail($sTO, $sSUBJECT, $sBODY);
var_dump($ret);  // (bool)true

… and open it in the browser to “send” the email.

In [WEBROOT]/vendor//emailcatcher/data/ it creates a textfile if the fetching was successful.

This will create a data file below ./vendor/emailcatcher/data/.

Exlude mail data file

If you extracted the sources (if no git clone was used): Exclude the file vendor/emailcatcher/data/emaildata.txt from commit into your project (eg. for git add it in the .gitignore file).