6
私はsymfony2フレームワークを試しています。私はswiftmailerとtwigを使って電子メールを送信しようとしています。問題は、私の現在の実装では、電子メールはhtmlで送られます(あなたはタグ、すべてを見ることができます)。Swiftmailer // Twig電子メールが正しくレンダリングされない
public function formularioAction()
{
$enquiry = new Enquiry();
$form = $this->createForm(new EnquiryType(), $enquiry);
$request = $this->getRequest();
if($request->getMethod() == 'POST'){
$form->bindRequest($request);
if($form->isValid()){
$message = \Swift_Message::newInstance()
->setSubject('Mail from the App')
->setFrom('[email protected]')
->setTo('******@gmail.com')
->setBody($this->render('AcmeDemoBundle:Demo:email.html.twig'));
$this->get('mailer')->send($message);
//end of mail sending
//redirect - it's important to prevent users from reposting the form if
//they refresh the page
return $this->redirect($this->generateUrl('_formulario'));
}
}
return $this->render('AcmeDemoBundle:Demo:formulario.html.twig', array('form' => $form->createView()));
}
そして小枝テンプレートを電子メールを使用している:私は間違って
{% extends "AcmeDemoBundle::layout.html.twig" %}
{% block title "Email de teste" %}
{% block content%}
<H1>Este é um render de um email de teste!</H1>
{% endblock%}
何をしているのでしょうか?ここで
は、私が使用しているコントローラでありますか