PHP code example of macklus / yii2-mailqueue
1. Go to this page and download the library: Download macklus/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/ */
macklus / yii2-mailqueue example snippets
return [
//....
'components' => [
'mailqueue' => [
'class' => 'dantart\mailqueue\MailQueue',
'table' => '{{%mail_queue}}',
'mailsPerRound' => 10,
'maxAttempts' => 3,
],
],
];
return [
//....
'components' => [
'mailqueue' => [
'class' => 'dantart\mailqueue\MailQueue',
'table' => '{{%mail_queue}}',
],
],
];
public function actionSend()
{
Yii::$app->mailqueue->process();
}
Yii::$app->mailqueue->compose('contact/html')
->setFrom('[email protected] ')
->setTo($form->email)
->setSubject($form->subject)
->setTextBody($form->body)
->queue();
return [
//....
'components' => [
'mailqueue' => [
'class' => 'dantart\mailqueue\MailQueue',
'table' => '{{%mail_queue}}',
'mailsPerRound' => 10,
'maxAttempts' => 3,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
],
];
Yii::$app->mailqueue->compose('contact/html')
->setFrom('[email protected] ')
->setTo($form->email)
->setSubject($form->subject)
->setTextBody($form->body)
->send();
php composer.phar
php yii migrate/up --migrationPath=@vendor/dantart/yii2-mailqueue/migrations/
*/10 * * * * php /var/www/html/myapp/yii mailqueue/process