承接 stampie/extra 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stampie/extra

最新稳定版本:v1.3.0

Composer 安装命令:

composer require stampie/extra

包简介

Event-based plugin for stampie/stampie

README 文档

README

CI

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

Usage

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

<?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.

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.

<?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.

<?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.

<?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.

统计信息

  • 总下载量: 228.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 4

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-18