Config mail.ru smtp

This commit is contained in:
iIronside 2023-10-18 10:48:38 +03:00
parent 5469a209a5
commit 233a8a6d10
9 changed files with 53 additions and 20 deletions

View File

@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'supp0rt.friday@yandex.ru',
'adminEmail' => 'chancellery@itguild.info',
];

View File

@ -1,9 +1,9 @@
<?php
return [
'adminEmail' => 'supp0rt.friday@yandex.ru',
'supportEmail' => 'supp0rt.friday@yandex.ru',
'senderEmail' => 'supp0rt.friday@yandex.ru',
'senderName' => 'Friday.support mailer',
'adminEmail' => 'chancellery@itguild.info',
'supportEmail' => 'chancellery@itguild.info',
'senderEmail' => 'chancellery@itguild.info',
'senderName' => 'Chancellery ITguild mailer',
'user.passwordResetTokenExpire' => 3600,
'user.passwordMinLength' => 8,
];

View File

@ -0,0 +1,10 @@
<?php
/* @var $this yii\web\View */
/* @var $user common\models\User */
?>
Hello <?= $user->username ?>,
You have successfully registered!

View File

@ -0,0 +1,10 @@
<?php
/* @var $this yii\web\View */
/* @var $user common\models\User */
?>
Hello <?= $user->username ?>,
You have successfully registered!

View File

@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'supp0rt.friday@yandex.ru',
'adminEmail' => 'chancellery@itguild.info',
];

View File

@ -8,7 +8,7 @@ $params = array_merge(
return [
'id' => 'app-frontend',
'name' => 'Guild',
'name' => 'itGuild',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',

View File

@ -1,4 +1,4 @@
<?php
return [
'adminEmail' => 'supp0rt.friday@yandex.ru',
'adminEmail' => 'chancellery@itguild.info',
];

View File

@ -45,24 +45,15 @@ class ContactForm extends Model
/**
* Sends an email to the specified email address using the information collected by this model.
*
* @param string $email the target email address
* @return bool whether the email was sent
*/
public function sendEmail($email)
public function sendEmail()
{
return Yii::$app->mailer->compose()
->setTo($this->email)
->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->params['senderName']])
// ->setReplyTo([$this->email => $this->name])
->setSubject($this->subject)
->setTextBody($this->body)
->send();
// return Yii::$app->mailer->compose()
// ->setTo($email)
// ->setFrom([$this->email => $this->name])
// ->setSubject($this->subject)
// ->setTextBody($this->body)
// ->send();
}
}

View File

@ -60,6 +60,28 @@ class SignupForm extends Model
$authorRole = $auth->getRole('user');
$auth->assign($authorRole, $user->id);
return $user->save() ? $user : null;
if ($user->save()) {
$this->sendEmail($user);
return $user;
} else {
return null;
}
}
/**
* Sends an email with a link, for resetting the password.
*
* @return bool whether the email was send
*/
private function sendEmail(User $user)
{
return Yii::$app->mailer->compose(
['html' => 'signup-html', 'text' => 'signup-text'],
['user' => $this]
)
->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->name . ' robot'])
->setTo($user->email)
->setSubject('Account registration at ' . Yii::$app->name)
->send();
}
}