elfuvo/yii2-postman

Collect E-mails from different sources for mailing

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

0.0.2 2021-06-20 13:14 UTC

This package is auto-updated.

Last update: 2024-12-20 21:22:48 UTC


README

Latest Stable Version Build Total Downloads License Yii2

Requirements

  • PHP >=7.1

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist elfuvo/postman "~0.0.2"

or add into composer.json

"elfuvo/postman": "~0.0.2"

Use:

In common config define classes

[
    'container' => [
        'definitions' =>[
            \elfuvo\postman\processor\ProcessorInterface::class => [
                'class' => \app\modules\postman\processor\MailProcessor::class,
                'collectors' => [
                    \elfuvo\postman\collector\TextInputCollector::class,
                ],
            ],
            \elfuvo\postman\result\ResultInterface::class => \elfuvo\postman\result\CacheContinuesResult::class,
        ],
    ]
];

For using DatabaseContinuesResult add migration path "@elfuvo/postman/migrations" to console config.

[
    'controllerMap' => [
        'migrate' => [
            'class' => \yii\console\controllers\MigrateController::class,
            'migrationTable' => '{{%migration}}',
            'useTablePrefix' => true,
            'interactive' => false,
            'migrationPath' => [
                '@elfuvo/postman/migrations',
            ],
        ]
    ]
];

in backend config define module

[
    'modules' => [
         'postman' => [
            'class' => \yii\base\Module::class,
            'controllerNamespace' => 'elfuvo\postman\controllers\backend',
        ],
    ]
];

if you don't want to use queue jobs create your own controller and set useQueue property for IndexAction as false

class DefaultController extends Controller
{
    /**
     * @return array|string[]
     */
    public function actions()
    {
        return [
            'index' => [
                'class' => IndexAction::class,
                'view' => '@app/modules/postman/views/backend/default/index', // path to custom template
                'useQueue' => true, // use or not Yii2 queue for mailing
            ],
            'progress' => ProgressAction::class,
            'view' => ViewAction::class,
        ];
    }
}

You can create custom collector of emails, see examples. After creating collector add it in common config.