I am trying to send Swift mail from the command line using the Symfony command. Although I get the following exception.
Fatal error: Call to undefined method Symfony\Bundle\TwigBundle\Debug\TimedTwigE ngine::renderView() in ...
The container that I got from the command made by ContainerAwareCommand added to this class
The function code is as follows:
private function sendViaEmail($content) { $message = \Swift_Message::newInstance() ->setSubject('Hello Email') ->setFrom('123@gmail.com') ->setTo('123@gmail.com') ->setBody( $this->container->get('templating')->renderView( 'BatchingBundle:Default:email.html.twig', array('content' => $content) ) ); $this->get('mailer')->send($message); }
Update The line where the exception occurs is $this->container->get('templating')->renderView(
As you can see in the code, the last line is likely to fail, and it finally gets there.
php swiftmailer symfony
Roel veldhuizen
source share