1. Go to this page and download the library: Download alexandresalome/mailcatcher library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexandresalome / mailcatcher example snippets
use Alex\MailCatcher\Behat\MailCatcherContext;
use Behat\Behat\Context\BehatContext;
class FeatureContext extends BehatContext
{
public function __construct(array $parameters)
{
$this->useContext('mailcatcher', new MailCatcherContext());
}
}
use Alex\MailCatcher\Behat\MailCatcherAwareInterface;
use Alex\MailCatcher\Behat\MailCatcherTrait;
use Alex\MailCatcher\Message;
use Behat\Behat\Context\Context;
class WelcomeContext implements Context, MailCatcherAwareInterface
{
use MailCatcherTrait;
/**
* @Then /^a welcome mail should be sent$/
*/
public function testTrait()
{
$this->findMail(Message::SUBJECT_CRITERIA, 'Welcome!');
}
}
// Message API, get the content of a message
$subject = $message->getSubject();
$plainTextBody = $message->getPart('text/plain')->getContent();
$htmlBody = $message->getPart('text/html')->getContent();
// Message API, return a Person object or an array of Person object
$person = $message->getFrom();
$persons = $message->getRecipients();
// Person API
$person = $message->getFrom();
$name = $person->getName(); // null means not provided
$mail = $person->getMail();
// Attachments
$message->hasAttachments();
$message->getAttachments();
// Delete
$message->delete();
// Attachment API
$attachment->getFilename();
$attachment->getSize();
$attachment->getType();
$attachment->getContent();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.