vision / yii2-queue-mails
Queue mails
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-11-29 04:57:39 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist vision/yii2-private-messages "@dev"
or add to the require section of your composer.json file.
"vision/yii2-queue-mails":"~1.0.0"
Configuration
Once the extension is installed, add following code to your application configuration :
'mailer' => [
'class' => 'vision\queue_mails\Mailer',
'mailsPerRound' => 5,
'realMailer' => [
'class' => '****',
'apikey' => '*****'
]
],
and /config/console.php:
'mailer' => [
'class' => 'vision\queue_mails\Mailer',
'mailsPerRound' => 5,
'realMailer' => [
'class' => '****',
'apikey' => '*****'
]
],
```
Following properties are available for customizing the mail queue behavior.
mailsPerRound: Number of emails to send at a time.
Run yii migrate command in command line:
php yii migrate --migrationPath=@vendor/vision/yii2-queue-mails/migrations
Most preferably this could be a console command (eg: mail/send) which can be triggered by a CRON job.
-----
Setting the CRON job
Set a CRON job to run console command:
*/10 * * * * php /var/www/html/myapp/yii mail/send
Usage
-----
Yii::$app->mailer->compose('contact/html', ['contactForm' => $form]) ->setFrom('from@domain.com') ->setTo($form->email) ->setSubject($form->subject) ->send();
Processing the mail queue
-----
Now calling Yii::$app->mailqueue->process() will process the message queue and send out the emails.