2017 © Pedro Peláez
 

library yii2-mailqueue

Message queue for emails extension for the Yii framework

image

cbm/yii2-mailqueue

Message queue for emails extension for the Yii framework

  • Saturday, April 11, 2015
  • by chrisb88
  • Repository
  • 2 Watchers
  • 1 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

Message queue for emails extension for Yii 2

This extension provides an email solution via message queueing for Yii 2. It comes ready for RabbitMQ. For other MQs you can provide your own "mqMessageClass" (see below) as long as it implements the QueueMessageInterface. You need of course a message queue like RabbitMQ installed., (*1)

Be aware that this extension is stable but not ready for production yet., (*2)

Please submit issue reports and pull requests to https://github.com/chrisb88/yii2-mailqueue., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist cbm/yii2-mailqueue

or add, (*6)

"cbm/yii2-mailqueue": "*"

to the require section of your composer.json., (*7)

Usage

Sample configuration:, (*8)

return [
    //....
    'components' => [
        // This is the message queue mailer config, it substitutes the original mailer config
        'mailer' => [
            'class' => 'cbm\mailqueue\QueueMailer',
            'mqMessageClass' => 'cbm\mailqueue\RabbitMessage',
            'mqConfig' => [
                'host' => 'localhost',
                'port' => 5672,
                'user' => 'guest',
                'password' => 'guest',
                'queue' => 'email_task',
                'publishRoutingKey' => 'email_task',
            ],
        ],
        // You also need the original yii swift mailer but with a different name
        'emailMailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            //....
        ],
    ],
];

You can then send an email to the queue as follows (no change to the original implementation):, (*9)

Yii::$app->mailer->compose('contact/html')
     ->setFrom('from@domain.com')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->send();

Don't forget to rename your original yii swift mailer to "emailMailer". It is still needed to really send the emails., (*10)

Get the email consumer running

Copy the file console/controller under your application console/controller (or where ever your console commands are) and run, (*11)

yii email-task

The consumer will then listen to email messages and send them using the original yii swift mailer., (*12)

The Versions

11/04 2015

dev-master

9999999-dev

Message queue for emails extension for the Yii framework

  Sources   Download

MIT

The Requires

 

by Christian Boehme

yii2 mailqueue

02/04 2015

0.1.0

0.1.0.0

Message queue for emails extension for the Yii framework

  Sources   Download

MIT

The Requires

 

by Christian Boehme

yii2 mailqueue