title: How can I send emails from a Symfony2 service class?
body: <p>I can use with success the followig code to send emails from the controller:</p>
  
  <pre><code>$message = \Swift_Message::newInstance()
      -&gt;setSubject('Hello Email')
      -&gt;setFrom('send@example.com')
      -&gt;setTo('recipient@example.com')
      -&gt;setBody($this-&gt;renderView('HelloBundle:Hello:email.txt.twig', array('name' =&gt; $name)))
  ;
  $this-&gt;get('mailer')-&gt;send($message);
  </code></pre>
  
  <p>How must i modify the code to use it from a service class?</p>