Conditions | 5 |
Paths | 8 |
Total Lines | 23 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | public function sendMessage(string $to, string $subject, string $view, array $params = []): bool |
||
34 | { |
||
35 | $message = \Yii::$app->getMailer()->compose($view, $params); |
||
36 | |||
37 | if (strlen($this->params->emailMain) && strlen($this->params->emailName)) { |
||
38 | $message->setFrom([$this->params->emailMain => $this->params->emailName]); |
||
39 | } |
||
40 | |||
41 | $message->setTo($to); |
||
42 | |||
43 | if (strlen($this->params->emailPrefix)) { |
||
44 | $message->setSubject($this->params->emailPrefix . ': ' . $subject); |
||
45 | } else { |
||
46 | $message->setSubject($subject); |
||
47 | } |
||
48 | |||
49 | try { |
||
50 | return $message->send(); |
||
51 | } catch (\Exception $e) { |
||
52 | Yii::error($e); |
||
53 | return false; |
||
54 | } |
||
55 | } |
||
56 | } |
||
57 |