Additional mail service for using coil and instant messaging in Symfony2 - weird headers

By default, I use the email solution to send a newsletter to my web page. But I also need to send an email immediately. Therefore i used this solution

If I send the newsletter with Spool, everything will be all right. But when I use

$mailer = $this->get('instant_mailer');

I get an email with some preliminary text at the beginning:

HTTP / 1.0 200 OK Cache-Control: no-cache Content-Type: text / html; charset = UTF-8 Date: Fri, 07 Sep 2012 16:19:06 GMT

How to remove this?

+5
source share
3 answers

I am sure that you are trying to send a Response object.

new Response();

it goes into __toString ()

public function __toString()
{
    $this->prepare();

    return
        sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n".
        $this->headers."\r\n".
        $this->getContent();
}

It's because:

$this->render('template.html.twig');

, :

$response = $this->render('template.html.twig');
$text = $response->getContent();

,

+7

$content = $this->renderView('template.html.twig');

$content = $this->render('template.html.twig');

render

+1

Another possible solution is to use the service templatinginstead of $this->render():

<?php
$body = $this->get('templating')->render('template.html.twig');
0
source

All Articles