symfony - Swift Emailer rare behaviour -
i have application developed in symfony 2. have contact form in bundle send me email. works code.
$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);
and in bundle in same application code not works
$message = \swift_message::newinstance() ->setsubject('test send emails other bundle') ->setfrom('xxxx@yahoo.es') //mail commented ->setto('xxxx@gmail.com') //mail commented ->setbody('hello'); $this->get('mailer')->send($message);
i don't understand happening. rare ... checked manual seems correct http://symfony.com/doc/2.1/cookbook/email/email.html
i added second parameter send method ->send($message, $failures); returns me array 0 items.
any clue?
edit: haved copied second code in first bundle , works fine. must bundle.
another clue? :)
symfony 2.1 needs return response send messages in memory. can return example redirect
, render
or forward
.
if not problem, try flush spool in controller force sending email. explained here
Comments
Post a Comment