title: yii2 mailer mail not sent
body: <p>There are absolutely two identical methods for sending mail (registration of a new user, <strong>sending a letter to activate the user</strong>). One method is implemented in the console, and it works:</p>
  
  <pre><code>public function actionSendMessage()
      {
          $user = new User();
          $this-&gt;readValue($user, 'username');
          $this-&gt;readValue($user, 'login');
          $this-&gt;readValue($user, 'email');
          $user-&gt;hash_password = Yii::$app-&gt;getSecurity()-&gt;generatePasswordHash($this-&gt;prompt('password'));
          $this-&gt;readValue($user, 'phone');
          $this-&gt;readValue($user, 'address');;
          $user-&gt;state = User::STATUS_WAIT;
          $user-&gt;generateAuthKey();
          $user-&gt;generateEmailConfirmToken();
          if ($user-&gt;save()) {
              Yii::$app-&gt;mailer-&gt;compose('@app/mail/emailConfirm', ['user' =&gt; $user])
                  -&gt;setFrom([Yii::$app-&gt;params['supportEmail'] =&gt; Yii::$app-&gt;name])
                  -&gt;setTo($user-&gt;email)
                  -&gt;setSubject('Email confirmation for ' . Yii::$app-&gt;name)
                  -&gt;send();
          }
      }
  </code></pre>
  
  <p>The second must send a letter when registering on the site, but alas, the letter does not come (<strong>no errors</strong>):</p>
  
  <pre><code>public function sign()
      {
  
          $user = new User();
          $user-&gt;username = $this-&gt;username;
          $user-&gt;login = $this-&gt;login;
          $user-&gt;email = $this-&gt;email;
          $user-&gt;hash_password = yii::$app-&gt;security-&gt;generatePasswordHash($this-&gt;password);
          $user-&gt;phone = $this-&gt;phone;
          $user-&gt;address = $this-&gt;address;
          $user-&gt;state = User::STATUS_WAIT;
          $user-&gt;generateAuthKey();
          $user-&gt;generateEmailConfirmToken();
          if ($user-&gt;save()) {
              Yii::$app-&gt;mailer-&gt;compose('@app/mail/emailConfirm', ['user' =&gt; $user])
                  -&gt;setFrom([Yii::$app-&gt;params['supportEmail'] =&gt; Yii::$app-&gt;name])
                  -&gt;setTo($user-&gt;email)
                  -&gt;setSubject('Email confirmation for ' . Yii::$app-&gt;name)
                  -&gt;send();
          }
  
      }
  </code></pre>
  
  <blockquote>
    <p>In what there can be an error? <code>$user-&gt;save()</code> <strong>is work</strong> for both actions.</p>
  </blockquote>