symfony - Emails are not send to the user -
i have problem sending emails raports. create data, , try send email user. emails not deliwered. using swiftmailer configured in symfony cookbool. parameters swiftmailer set because emails fosuserbundle working without problems. have write method use in comand line, code below
class dailyraportcommand extends containerawarecommand { protected function configure() { $this ->setname('raport:daily') ->setdescription('send daily raports users'); } protected function execute(inputinterface $input, outputinterface $output) { $em = $this->getcontainer()->get('doctrine')->getentitymanager(); $users = $em->getrepository('gluserbundle:user')->findallbyraport('daily'); foreach($users $user) { $date_to = new \datetime(); $date_to = $date_to->sub(date_interval_create_from_date_string('1 day')); $date_from = new \datetime(); $date_from = $date_from->sub(date_interval_create_from_date_string('1 day')); $format = "y-m-d"; $raport = array(); foreach($user->getshops() $shop) { $raport[$shop->getname()] = array(); $shop_list = array(); $shop_list[] = $shop->getid(); $groupby = array(); $all_policies = $em->getrepository('glpolicybundle:policy') ->findallbyoptions($shop_list, $date_from, $date_to, $groupby); $raport[$shop->getname()]['all'] = $all_policies; $groupby[] = 'typepolicy'; $policies_by_type = $em->getrepository('glpolicybundle:policy') ->findallbyoptions($shop_list, $date_from, $date_to, $groupby); $raport[$shop->getname()]['type'] = $policies_by_type; $groupby[] = 'bundle'; $policies_by_bundle = $em->getrepository('glpolicybundle:policy') ->findallbyoptions($shop_list, $date_from, $date_to, $groupby); $raport[$shop->getname()]['bundle'] = $policies_by_bundle; } $message = \swift_message::newinstance() ->setsubject('dzienny raport sprzedaży') ->setfrom('g#######1@gmail.com') ->setto($user->getemail()) ->setbody( $this->getcontainer()->get('templating')->render( 'glraportbundle:raport:raport.html.twig', array('raport' => $raport) )); $this->getcontainer()->get('mailer')->send($message); }
the wiev of email rendered in outside twig file. grateful if point whots reason of problem.
you might need manually flush memory spool, see following answer helped me same problem:
unable send e-mail within custom symfony2 command can elsewhere in app
Comments
Post a Comment