2017 © Pedro Peláez
 

library stampie-extra

Event-based plugin for stampie/stampie

image

stof/stampie-extra

Event-based plugin for stampie/stampie

  • Saturday, November 18, 2017
  • by Stof
  • Repository
  • 1 Watchers
  • 16 Stars
  • 26,974 Installations
  • PHP
  • 1 Dependents
  • 3 Suggesters
  • 3 Forks
  • 1 Open issues
  • 4 Versions
  • 16 % Grown

The README.md

Stampie Extra

CI, (*1)

StampieExtra provides an event-based extension point for Stampie. It uses the Symfony EventDispatcher component., (*2)

Usage

The Stampie Extra mailer wraps your Stampie mailer to provides extension points in the sending process., (*3)

<?php

// 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

$mailer->send($message);

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

Built-in listeners

ImpersonateListener

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., (*5)

<?php
$dispatcher->addEventSubscriber(new Stampie\Extra\EventListener\ImpersonateListener('stampie@example.com'));

LoggerListener

The LoggerListener allows you to log sent emails. It expects a logger implementing the PSR-3 LoggerInterface., (*6)

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

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

SpoolMailer

Stampie Extra also provides a SpoolMailer storing the messages in memory and sending them when flushing the queue., (*7)

<?php

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

$message = // Create your Stampie message...
$spoolMailer->send($message);

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

// Flush the queue, sending the message with the inner mailer
$spoolMailer->flushSpool();

Testing

Stampie Extra is Continuous Integration tested with Travis and aims for a high coverage percentage., (*8)

The Versions

08/06 2017
18/07 2014

v0.2.0

0.2.0.0 https://github.com/stof/StampieExtra

Event-based plugin for henrikbjorn/stampie

  Sources   Download

MIT

The Requires

 

The Development Requires

10/01 2013

v0.1.0

0.1.0.0 https://github.com/stof/StampieExtra

Event-based plugin for henrikbjorn/stampie

  Sources   Download

MIT

The Requires

 

The Development Requires