mirror of
https://github.com/elyby/accounts.git
synced 2024-12-02 11:41:05 +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 Ramsey\Uuid\Uuid;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ErrorException;
|
use yii\base\ErrorException;
|
||||||
|
use yii\base\InvalidConfigException;
|
||||||
|
|
||||||
class RegistrationForm extends ApiForm {
|
class RegistrationForm extends ApiForm {
|
||||||
|
|
||||||
@ -101,6 +102,12 @@ class RegistrationForm extends ApiForm {
|
|||||||
public function sendMail(EmailActivation $emailActivation, Account $account) {
|
public function sendMail(EmailActivation $emailActivation, Account $account) {
|
||||||
/** @var \yii\swiftmailer\Mailer $mailer */
|
/** @var \yii\swiftmailer\Mailer $mailer */
|
||||||
$mailer = Yii::$app->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 */
|
/** @var \yii\swiftmailer\Message $message */
|
||||||
$message = $mailer->compose([
|
$message = $mailer->compose([
|
||||||
'html' => '@app/mails/registration-confirmation-html',
|
'html' => '@app/mails/registration-confirmation-html',
|
||||||
@ -109,7 +116,7 @@ class RegistrationForm extends ApiForm {
|
|||||||
'key' => $emailActivation->key,
|
'key' => $emailActivation->key,
|
||||||
])
|
])
|
||||||
->setTo([$account->email => $account->username])
|
->setTo([$account->email => $account->username])
|
||||||
->setFrom([Yii::$app->params['fromEmail'] => 'Ely.by Accounts'])
|
->setFrom([$fromEmail => 'Ely.by Accounts'])
|
||||||
->setSubject('Ely.by Account registration');
|
->setSubject('Ely.by Account registration');
|
||||||
|
|
||||||
if (!$message->send()) {
|
if (!$message->send()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user