title: Symfony 2: how to send an email using Swiftmailer
body: <p>I am trying to send emails using Swiftmailer with Symfony 2.</p>
  
  <p>This is the simple function in the controller</p>
  
  <pre><code>public function sendEmailAction() {
  
   $name = 'Test';
  
   $mailer = $this-&gt;get('mailer');
   $message = $mailer-&gt;createMessage()
      -&gt;setSubject('Ciao')
      -&gt;setFrom('send@example.com')
      -&gt;setTo('recipient@example.com')
      -&gt;setBody($this-&gt;renderView('dashboard/email.html.twig',array('name' =&gt; $name)), 'text/html');
  
  
  
      $mailer-&gt;send($message);
  
     return $this-&gt;redirectToRoute('dashboard');
  </code></pre>
  
  <p>In the parameters.yml I have following configuration</p>
  
  <pre><code>parameters:
  database_host: 127.0.0.1
  database_port: null
  database_name: symfony
  database_user: root
  database_password: null
  mailer_transport: smtp
  mailer_host: 127.0.0.1
  mailer_user: null
  mailer_password: null
  secret: e23a8d7b075fa3c7e56b10186a24cf2790a3169a
  </code></pre>
  
  <p>And this is the <strong>config.yml</strong> one</p>
  
  <pre><code># Swiftmailer Configuration
  swiftmailer:
  transport: "%mailer_transport%"
  host:      "%mailer_host%"
  username:  "%mailer_user%"
  password:  "%mailer_password%"
  spool:     { type: memory }
  </code></pre>
  
  <p>Unfortunately I cannot send emails...</p>