Config mail.ru smtp
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
<?php
 | 
			
		||||
return [
 | 
			
		||||
    'adminEmail' => 'supp0rt.friday@yandex.ru',
 | 
			
		||||
    'adminEmail' => 'chancellery@itguild.info',
 | 
			
		||||
];
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
];
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								common/mail/signup-html.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								common/mail/signup-html.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/* @var $this yii\web\View */
 | 
			
		||||
/* @var $user common\models\User */
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
Hello <?= $user->username ?>,
 | 
			
		||||
 | 
			
		||||
You have successfully registered!
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								common/mail/signup-text.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								common/mail/signup-text.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
/* @var $this yii\web\View */
 | 
			
		||||
/* @var $user common\models\User */
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
Hello <?= $user->username ?>,
 | 
			
		||||
 | 
			
		||||
You have successfully registered!
 | 
			
		||||
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
<?php
 | 
			
		||||
return [
 | 
			
		||||
    'adminEmail' => 'supp0rt.friday@yandex.ru',
 | 
			
		||||
    'adminEmail' => 'chancellery@itguild.info',
 | 
			
		||||
];
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ $params = array_merge(
 | 
			
		||||
 | 
			
		||||
return [
 | 
			
		||||
    'id' => 'app-frontend',
 | 
			
		||||
    'name' => 'Guild',
 | 
			
		||||
    'name' => 'itGuild',
 | 
			
		||||
    'basePath' => dirname(__DIR__),
 | 
			
		||||
    'bootstrap' => ['log'],
 | 
			
		||||
    'controllerNamespace' => 'frontend\controllers',
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
<?php
 | 
			
		||||
return [
 | 
			
		||||
    'adminEmail' => 'supp0rt.friday@yandex.ru',
 | 
			
		||||
    'adminEmail' => 'chancellery@itguild.info',
 | 
			
		||||
];
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,29 @@ class SignupForm extends Model
 | 
			
		||||
        $auth = Yii::$app->authManager;
 | 
			
		||||
        $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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user