6

I have an action that lets the customer preview system email messages and i want to send a text/plain header for the plaintext versions of the emails.

I tried to follow the Symfony docs : Requests and Responses in Symfony section. However my controller is sending a text/html content-type no matter what i do.

This is my action:

function showAction($action = null, $format = null){

   $locale = $this->get('session')->getLocale();
   $format = $this->getRequest()->get("format");
   $format = isset($format) ? $format : 'html';


   if ($format === 'text'){
       $response = new Response();
       $response->headers->set('Content-Type', 'text/plain');
       $response->sendHeaders();

   }

   $view = sprintf('MyBundle:Email:%s.%s.%s.twig', 
         $action,$locale,$format);

   return $this->render($view, array());
}

So how do I send a text plain header and where am I going wrong?

1 Answer 1

13

You need to add $response to render call

return $this->render($view, array(), $response);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.