Search code examples
symfonytwigswiftmailer

using swift mailer of symfony 2, got an email but getting unnecessary response in email


getting this response by email "HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: text/html; charset=UTF-8 Date: Tue, 13 Nov 2012 04:56:14 GMT".

here is my code:

 public function sendEmail($subject, $template, $templateParams)
    {
        $userEmail = $this->session->get('email');
        $name = $this->session->get('name');
        $adminEmail = $this->container;
        $templateParams['username'] = $name; 
        $message = \Swift_Message::newInstance()
                ->setSubject($subject)
                ->setFrom($adminEmail)
                ->setTo($userEmail)
                ->setBody($this->templating->render('SocialDonSocialBundle:Email:'.$template,$templateParams), 'text/html'); 
        $this->mailer->send($message);

Also note that this method is belongs to a service namely "Email". I have created a service "Email " which responsible to send emails. Does anybody know what might be the issue??


Solution

  • You need to use renderView() instead of render(), because render() always display the header.