PHP code example of yiicod / yii2-mailqueue

1. Go to this page and download the library: Download yiicod/yii2-mailqueue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yiicod / yii2-mailqueue example snippets


php yii migrate/up --migrationPath=@vendor/yiicod/yii2-mailqueue/migrations

'i18n' => [
    'translations' => [
        '*' => [
            'class' => 'yii\i18n\PhpMessageSource'
        ],
    ],
],

'components' => [
    'mailqueue' => [
        'class' => 'yiicod\mailqueue\WorkerCommand',
    ],
]
...
'bootstrap' => array('mailqueue')

'commandMap' => [
    'mail-queue' => [
        'class' => 'yiicod\mailqueue\commands\MailQueueCommand',
    ],
],

'commandMap' => [
    'mail-queue' => [
        'class' => 'yiicod\mailqueue\commands\WorkerCommand',
    ],
],

   yii migrate --migrationPath=@yiicod/mailqueue/migrations

/**
 * Add mail from queue
 * @param string $to Email to
 * @param string $subject Email subject
 * @param string $body email, html
 * @param string|Array $from From email
 * @param string $attachs Attach for email array('path' => 'file path', 'name' => 'file bname')
 * @param Array $additionalFields Any additional fields
 */
Yii::app()->mailQueue->push($to, $subject, $body, $from = '', array $attachs = [], $additionalFields = []);

/**
 * Push mass
 * array(
 *    array(
 *      'field name to' => '',
 *      'field name subject' => '',
 *      'field name body' => '',
 *      'field name priority' => '',
 *      'field name from' => '',
 *      'field name attachs' => '',
 *    )
 * )
 * @param Array $data
 * @return int Return int
 */
Yii::app()->mailQueue->pushMass($data)

php composer.phar