title: How can i use Swift mailer in my php code in symfony
body: <p>I am using this but i am getting error</p>
  
  <pre><code>foo_bundle.listener.comment:
          class: xxx\Listener\CupleListener
          arguments: [@mailer]
  </code></pre>
  
  <hr>
  
  <pre><code>class CupleListener
  {
      protected $mailer;
  
      public function __construct(Swift_Mailer $mailer)
      {
          $this-&gt;mailer = $mailer;
      }
  
      public function onCenterEvent(CupleEvent $event)
      {
          $center = $event-&gt;getcenter();
  
              $message = \Swift_Message::newInstance()
              -&gt;setSubject('New comment posted on ' . $post-&gt;getTitle())
              -&gt;setFrom('send@example.com')
              -&gt;setTo('xxxxxxxxxx')
              -&gt;setBody("Hey, somebody left a new comment on a post you're subscribed to! It says: " . $comment-&gt;getBody());
              $this-&gt;mailer-&gt;send($message);
  
      }
  }
  </code></pre>
  
  <p>This is giving error</p>
  
  <p>Also i don't know which class to include on the top of namespace</p>