MailerQueueController.php
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace backend\controllers;
use Yii;
use common\components\DbSpool;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* MailerQueueController implements the CRUD actions for MailerQueue model.
*/
class MailerQueueController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Send Queue messages
*/
public function actionSend()
{
$messageLimit = 10;
$timeLimit = 0;
$spool = new DbSpool();
$transportReal = \Swift_SmtpTransport::newInstance(
"smtp.gmail.com",
"465",
"ssl"
)
->setUsername("alexandr.khivrich@gmail.com")
->setPassword("10181997Nadia");
$spool->setMessageLimit($messageLimit);
$spool->setTimeLimit($timeLimit);
$sent = $spool->flushQueue($transportReal);
echo sprintf('sent %s emails', $sent);
}
}