title: Sending Mail - Yii 2.0
body: <p>I'm trying to send mail, but getting error like.</p>
  <blockquote>
  <p>Unknown Property – yii\base\UnknownPropertyException</p>
  <p>Getting unknown property: yii\web\Application::mail</p>
  </blockquote>
  <p>After changing <code>Yii::$app-&gt;mail-&gt;compose()</code> to <code>Yii::$app-&gt;mailer-&gt;compose()</code>
  I got this error</p>
  <blockquote>
  <p>Invalid Parameter – yii\base\InvalidParamException</p>
  <p>Invalid path alias:@backend/mail</p>
  </blockquote>
  <p>I'm not getting where i'm doing mistake.</p>
  <p>I'm using yii-app-basic.</p>
  <p><strong>config/console.php</strong></p>
  <pre><code>...
      'components' =&gt; [
          'mailer' =&gt; [
              'class' =&gt; 'yii\swiftmailer\Mailer',
          ],
      ],
  ...
  </code></pre>
  <p><strong>config/web.php</strong></p>
  <pre><code>...
      'components' =&gt; [
          'mailer' =&gt; [
              'class' =&gt; 'yii\swiftmailer\Mailer',
              'viewPath' =&gt; '@backend/mail',
              'useFileTransport' =&gt; true,
              'transport' =&gt; [
                  'class' =&gt; 'Swift_SmtpTransport',
                  'host' =&gt; 'localhost',
                  'username' =&gt; 'root',
                  'password' =&gt; '',
                  'port' =&gt; '8080',
                  'encryption' =&gt; 'tls',
              ],
          ],
      ],
  ...
  </code></pre>
  <p><strong>SiteController.php</strong></p>
  <pre><code>&lt;?php
  
  namespace app\controllers;
  
  use Yii;
  use yii\filters\AccessControl;
  use yii\web\Controller;
  use yii\filters\VerbFilter;
  use yii\swiftmailer\Mailer;
  
  class SiteController extends Controller
  {
      public function actionRegister()
      {
          Yii::$app-&gt;mail-&gt;compose()
                  -&gt;setFrom('enamRaj@gmail.com')
                  -&gt;setTo('Raj@infotech.com')
                  -&gt;setSubject('This is a test mail')
                  -&gt;send();
      }
  }
  </code></pre>
  <p>Error Screenshot
  <a href="https://i.stack.imgur.com/PetjT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PetjT.png" alt="enter image description here" /></a></p>
  <p>I'm new to Yii. I don't have much idea. If this is a silly question,please forgive me.</p>
  <p>Taking help from <a href="http://www.yiiframework.com/doc-2.0/guide-tutorial-mailing.html" rel="nofollow noreferrer">Mailing- Yii 2.0</a>. But, not getting much idea.
  Please help me to send email</p>