title: Yii2 SwiftMailer sending email via remote smtp server (gmail)
body: <p>I want to send emails via my gmail account.</p>
  
  <p>My mailer config:</p>
  
  <pre><code>[
  'class' =&gt; 'yii\swiftmailer\Mailer',
  'useFileTransport' =&gt; false,//set this property to false to send mails to real email addresses
  'transport' =&gt; [
      'class' =&gt; 'Swift_SmtpTransport',
      'host' =&gt; 'smtp.gmail.com',
      'username' =&gt; 'my@gmail.com',
      'password' =&gt; 'pass',
      'port' =&gt; '587',
      'encryption' =&gt; 'tls',
      ],
  ]
  </code></pre>
  
  <p>I wrote command MailController:</p>
  
  <pre><code>&lt;?php
  
  namespace app\commands;
  
  use yii\console\Controller;
  use Yii;
  
  /**
  * Sanding mail
  * Class MailController
  * @package app\commands
  */
  class MailController extends Controller
  {
      private $from = 'my@gmail.com';
      private $to = 'to@gmail.com';
  
      public function actionIndex($type = 'test', $data = null)
      {
          Yii::$app-&gt;mailer-&gt;compose($type, ['data' =&gt; $data])
              -&gt;setFrom($this-&gt;from)
              -&gt;setTo($this-&gt;to)
              -&gt;setSubject($this-&gt;subjects[$type])
              -&gt;send();
      }
  }
  </code></pre>
  
  <p>When I'm trying to run: <code>php yii mail</code></p>
  
  <p>I get: <code>sh: 1: /usr/sbin/sendmail: not found</code></p>
  
  <p>But why it requires sendmail if I want just SMTP connection to smtp.gmail.com?</p>