2013-04-18 3 views
0

Symfony 2에서 개발 한 응용 프로그램이 있습니다. 전자 메일을 보내는 번들로 연락 양식이 있습니다. 이 코드와 함께 작동합니다. Swift Emailer 드문 행동

$message = \Swift_Message::newInstance() 
->setSubject('Nueva consulta desde el formulario de contacto') 
->setFrom($contacto->getEmail()) 
->setTo($this->container->getParameter('portada.emails.contact_email')) 
->setBody($this->renderView('PortadaBundle:Page:contactoEmail.txt.twig', array('contacto' => $contacto))); 

$this->get('mailer')->send($message); 

그리고이 코드는하지

$message = \Swift_Message::newInstance() 
->setSubject('Test to send emails from other bundle') 
->setFrom('[email protected]') //mail commented 
->setTo('[email protected]') //mail commented 
->setBody('Hello'); 

$this->get('mailer')->send($message); 

내가 무슨 일이 일어나고 있는지 이해가 안 WORKS 같은 응용 프로그램에서 다른 번들

. 너무 희귀합니다 ... 설명서를 확인했지만 모두 정확해 보입니다. http://symfony.com/doc/2.1/cookbook/email/email.html

두 번째 매개 변수를 추가하여 메서드 -> send ($ message, $ failureures)를 보냈습니다. 하지만 그것은 나에게 항목이없는 배열을 반환합니다.

단서가 있습니까?

편집 : 첫 번 째 번들에 두 번째 코드가 복사되어 정상적으로 작동합니다. 번들에 관한 것이어야합니다.

또 다른 단서? :)

+0

어떤 버전을 사용하고 있습니까? 당신은'$ this-> get ('mailer') -> send ($ message);'? – Erioch

+0

Symfony 2.1. 예, 응답이 '1'이됩니다. – Freenando

답변

0

Symfony 2.1은 메시지를 메모리에 보내기 위해 response을 반환해야합니다. 예를 들어 redirect, render 또는 forward을 반환 할 수 있습니다.

문제가되지 않으면 컨트롤러에서 스풀을 비워서 전자 메일 보내기를 시도하십시오. 설명되어 있습니다 here

+0

예, 이것이 첫 번째 옵션입니다. 리디렉션, 렌더링 또는 전달해야합니다 ... 감사합니다! – Freenando