2017 © Pedro Peláez
 

library yii2-email-manager

Yii2 Email Manager

image

frenzelgmbh/yii2-email-manager

Yii2 Email Manager

  • Monday, February 6, 2017
  • by philippfrenzel
  • Repository
  • 2 Watchers
  • 0 Stars
  • 40 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Email Module

Enhanced E-Mail Module based upon the original code from:, (*1)

yarcode/yii2-email-manager, (*2)

Had to adpopt a couple of things to use it within our projects. Feel free to participate;), (*3)

Installation

Add the following line to your composer.json require section:, (*4)

"FrenzelGmbH/yii2-email-manager" : "*",

After this you have to modify your configuration files like:, (*5)

Simple configuration:, (*6)

'components' => [
    'emailManager' => [
        'class' => '\net\frenzel\email\EmailManager',
        'transports' => [
            'yiiMailer' => '\net\frenzel\email\transports\YiiMailer'
        ],
    ],
]

Multi transport configuration:, (*7)

'components' => [
    'emailManager' => [
        'class' => '\net\frenzel\email\EmailManager',
        'defaultTransport' => 'yiiMailer',
        'transports' => [
            'yiiMailer' => [
                'class' => '\net\frenzel\email\transports\YiiMailer',
            ],
        ],
    ],
]

Add command to the list of the available commands. Put it into console app configuration:, (*8)

'controllerMap' => [
    'email' => '\net\frenzel\email\commands\EmailCommand',
],

Add email sending daemon into crontab via lockrun or run-one utils:, (*9)

*/5 * * * * run-one php /your/site/path/yii email/run-spool-daemon

OR, if you will use cboden/ratchet, (*10)

*/5 * * * * run-one php /your/site/path/yii email/run-loop-daemon

Usage

// obtain component instance
$emailManager = EmailManager::geInstance();
// direct send via default transport
$emailManager->send('from@example.com', 'to@example.com', 'test subject', 'test email');
// queue send via default transport
$emailManager->send('from@example.com', 'to@example.com', 'test subject', 'test email');
// direct send via selected transport
$emailManager->transports['mailGun']->send('from@example.com', 'to@example.com', 'test subject', 'test email');

// use shortcuts
EmailTemplate::findByShortcut('shortcut_name')->queue('recipient@email.org', ['param1' => 1, 'param2' => 'asd']);

The Versions

19/01 2016