Event-based plugin for stampie/stampie

v1.3.0 2022-05-03 22:03 UTC

This package is auto-updated.

Last update: 2024-06-30 00:52:26 UTC


Stampie Extra


StampieExtra provides an event-based extension point for Stampie. It uses the Symfony EventDispatcher component.


The Stampie Extra mailer wraps your Stampie mailer to provides extension points in the sending process.


// include the Composer autoloading
require 'vendor/autoload.php';

$httpClient = new Http\Adapter\Guzzle6\Client();
$innerMailer = new Stampie\Mailer\SendGrid($httpClient, 'username:password');

$dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$mailer = new Stampie\Extra\Mailer($innerMailer, $dispatcher);

$message = // Create your Stampie message


The mailer will then dispatch the stampie.pre_send event before sending the message, allowing you to apply some changes.

Built-in listeners


The ImpersonateListener allows you to replace the recipient of the mail during development to send all messages to a single email address. It will add a X-Stampie-To header containing the original recipient.

$dispatcher->addEventSubscriber(new Stampie\Extra\EventListener\ImpersonateListener(''));


The LoggerListener allows you to log sent emails. It expects a logger implementing the PSR-3 LoggerInterface.

// create a listener and configure it
$logger = new Monolog\Logger('stampie');
// ...

$dispatcher->addEventSubscriber(new Stampie\Extra\EventListener\LoggerListener($logger));


Stampie Extra also provides a SpoolMailer storing the messages in memory and sending them when flushing the queue.


$mailer = // Create your mailer...
$spoolMailer = new Stampie\Extra\SpoolMailer($mailer);

$message = // Create your Stampie message...

// Do some logic, for instance flushing the response to the user

// Flush the queue, sending the message with the inner mailer


Stampie Extra is Continuous Integration tested with Travis and aims for a high coverage percentage.