27 lines
555 B
PHP
27 lines
555 B
PHP
<?php
|
|
|
|
namespace common\helpers;
|
|
|
|
use Yii;
|
|
|
|
class MailHelper
|
|
{
|
|
static public function sendMail($emailTo, $emailFrom, $subject, $body, $view = null): bool
|
|
{
|
|
if (!$emailFrom) {
|
|
$emailFrom = [Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']];
|
|
}
|
|
|
|
return Yii::$app
|
|
->mailer
|
|
->compose(
|
|
$view,
|
|
$body
|
|
)
|
|
->setFrom($emailFrom)
|
|
->setTo($emailTo)
|
|
->setSubject($subject)
|
|
->send();
|
|
}
|
|
}
|