私はsymfony2フレームワークを試していて、swiftmailerとtwigを使用してメールを送信しようとしています。問題は、私の現在の実装では、電子メールがhtmlで送信されることです(タグ、すべてを見ることができます)。
これが私が使用しているコントローラーです:
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('no-reply@app.com')
->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%}
私は何が間違っているのですか?