mirror of
https://github.com/elyby/accounts.git
synced 2024-11-30 02:32:26 +05:30
Добавил эксепшен в случае утсутствия мыла.
З.Ы. Туда бы di в тот класс... :)
This commit is contained in:
parent
a69cd2da2c
commit
067fc1d3d6
@ -9,6 +9,7 @@ use common\models\EmailActivation;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
use yii\base\InvalidConfigException;
|
||||
|
||||
class RegistrationForm extends ApiForm {
|
||||
|
||||
@ -101,6 +102,12 @@ class RegistrationForm extends ApiForm {
|
||||
public function sendMail(EmailActivation $emailActivation, Account $account) {
|
||||
/** @var \yii\swiftmailer\Mailer $mailer */
|
||||
$mailer = Yii::$app->mailer;
|
||||
$fromEmail = Yii::$app->params['fromEmail'];
|
||||
|
||||
if (!$fromEmail) {
|
||||
throw new InvalidConfigException('Please specify fromEmail app in app params');
|
||||
}
|
||||
|
||||
/** @var \yii\swiftmailer\Message $message */
|
||||
$message = $mailer->compose([
|
||||
'html' => '@app/mails/registration-confirmation-html',
|
||||
@ -109,7 +116,7 @@ class RegistrationForm extends ApiForm {
|
||||
'key' => $emailActivation->key,
|
||||
])
|
||||
->setTo([$account->email => $account->username])
|
||||
->setFrom([Yii::$app->params['fromEmail'] => 'Ely.by Accounts'])
|
||||
->setFrom([$fromEmail => 'Ely.by Accounts'])
|
||||
->setSubject('Ely.by Account registration');
|
||||
|
||||
if (!$message->send()) {
|
||||
|
Loading…
Reference in New Issue
Block a user