変数名でメールを送信したい。次のようにアクションを作成しました。
$product = $this->getDoctrine()
->getRepository('EnsNewBundle:Products')
->find(2);
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('ucerturohit@gmail.com')
->setTo('ucerturohit@gmail.com')
->setContentType("text/html")
->setBody($this->renderView('EnsNewBundle:Default:index.html.twig'));
$this->get('mailer')->send($message);
return $this->render('EnsNewBundle:Default:index.html.twig',array('name'=>$product->getName()));
$product->getName()
ここではメールでデータを送信したいと思います。index.html.twig
私は次のように定義しました:
Id of the product 5<br/>
Name of the product {{name}} <br/>
Description Fast Internet browsing speed
このアクションを実行すると、エラーが発生しますundefined variable name in index.html.twig
。メールを送信する前にこの値を設定したい場合はどうすればよいですか。メール本文のハードコードを作成しても問題ありません。