shaqman/yii2-queue-mailer

Background mailer decorator for Yii2

Maintainers

👁 shaqman

Package info

github.com/shaqman/yii2-queue-mailer

Type:yii2-extension

pkg:composer/shaqman/yii2-queue-mailer

Statistics

Installs: 20 989

Dependents: 1

Suggesters: 0

Stars: 8

Open Issues: 0

0.3.0 2018-03-11 08:30 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT b6860e04e674fcc7da7b7af0547b57d5dc188b78

  • Alexey Samoylov <alexey.samoylov.woop@gmail.com>
  • Syakur Rahman <shaqman2004.woop@yahoo.com>

mailerqueuebackgroundyii2

This package is auto-updated.

Last update: 2026-06-05 22:38:27 UTC


README

Background mailer for Yii2 using any queue interface. This extension was tested with yii2 queue extension.

This extension was tested only with swiftmailer extension, though it should work with any compatible mailer extension

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist shaqman/yii2-queue-mailer

or add

"shaqman/yii2-queue-mailer": "*"

Usage

Configure queue component of your application.

You can find the details here: https://github.com/yiisoft/yii2-queue/

Configure \shaqman\mailer\queuemailer\Mailer as your primary mailer.

 'mailer' => [
 'class' => \shaqman\mailer\queuemailer\Mailer::class,
 'queue' => 'queue' // name of queue component, or a valid array configuration for it.
 'syncMailer' => [ // Any valid mailer should work
 'class' => 'yii\swiftmailer\Mailer',
 'useFileTransport' => true,
 ],
 ],

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')
 ->send($message);

One small difference should be noted compared to the default send. It now returns an int identifying the queue id that the mail was assigned to. This is to be expected since there is no way to know whether the mail was successfully sent at the time of the command was executed.