-
Notifications
You must be signed in to change notification settings - Fork 1
/
MPMailer.php
71 lines (60 loc) · 1.24 KB
/
MPMailer.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Created by PhpStorm.
* User: Yarmaliuk Mikhail
* Date: 26.06.2017
* Time: 18:21
*/
namespace Kakadu\Yii2BaseHelpers;
use yii\swiftmailer\Mailer;
/**
* Class MPMailer
* @package Kakadu\Yii2BaseHelpers
* @author Yarmaliuk Mikhail
* @version 1.0
*/
class MPMailer extends Mailer
{
/**
* @var NULL
*/
private $_toUser = null;
/**
* @inheritdoc
*/
public function compose($view = null, array $params = [])
{
if (!empty($params['toUser'])) {
$this->_toUser = $params['toUser'];
}
return parent::compose($view, $params);
}
/**
* @inheritdoc
*/
public function send($message)
{
$bccList = $message->getBcc();
$message->setBcc([]);
$result = parent::send($message);
// Send bcc
if ($result && !empty($bccList)) {
foreach ($bccList as $key => $bcc) {
$message
->setTo([$key => $bcc])
->setBcc([])
->send();
}
}
return $result;
}
/**
* Get message recipient
*
* @return NULL
*/
public function getToUser()
{
return $this->_toUser;
}
}