title: Send mail from localhost via Symfony2 Command using Swiftmailer
body: <p><strong>Command function</strong></p>
  
  <pre><code>$message = \Swift_Message::newInstance('test')
              -&gt;setContentType("text/html")
              -&gt;setFrom('x@x.com')
              -&gt;setTo('x@gmail.com');
  
          $message-&gt;setBody('test');
  
          if ($this-&gt;getApplication()-&gt;getKernel()-&gt;getContainer()-&gt;get('mailer')-&gt;send($message))
          {
              return true;
          }
          return false;
  </code></pre>
  
  <p>When I execute command in Command Line I get true like mail is sent.</p>
  
  <p><strong>Paramters.yml</strong></p>
  
  <pre><code>mailer_transport: gmail
  mailer_host: smtp.gmail.com
  mailer_user: x@gmail.com
  mailer_password: xxxxxxxxxxxxx
  </code></pre>
  
  <p><strong>Config.yml</strong></p>
  
  <pre><code>swiftmailer:
      spool:
          type: file
          path: "%kernel.root_dir%/../swiftmailer"
      transport: %mailer_transport%
      host:      %mailer_host%
      username:  %mailer_user%
      password:  %mailer_password%
  </code></pre>
  
  <p>I had read somewhere that Symfony Profiler can be used to see if mail has sent but I just want to physically send mail to my address in testing purpose. I just need info where I do wrong things.</p>
  
  <p>I must <strong>notice</strong> that I using <strong>allowed device security tool</strong> in gmail account. </p>
  
  <p>Can that be reason why mail is not sent?</p>