2012-09-11 10 views
6

Sto sperimentando con il framework symfony2 e sto provando a inviare e-mail usando swiftmailer e twig. Il problema è che, con la mia attuale implementazione, l'email viene inviata in html (puoi vedere i tag, tutto).Swiftmailer // L'e-mail di ramoscello non viene visualizzata correttamente

Ecco il controller sto usando:

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())); 
} 

E ramoscello modello l'e-mail sta usando:

{% extends "AcmeDemoBundle::layout.html.twig" %} 

{% block title "Email de teste" %} 

{% block content%} 
<H1>Este é um render de um email de teste!</H1> 
{% endblock%} 

Che cosa sto facendo di sbagliato?

risposta