getRepository()->findProducers(); foreach($producersArray as $producer) { \Yii::$app->logic->setProducerContext($producer); $automaticEmailsArray = $automaticEmailModule->getRepository()->findAutomaticEmails(); foreach($automaticEmailsArray as $automaticEmail) { $distribution = $automaticEmailModule->getResolver()->getMatchedDistribution($automaticEmail); if($distribution) { $email = $automaticEmailModule->getManager()->createEmailFromAutomaticEmail($automaticEmail, $distribution); $usersArray = $emailModule->getContactListResolver()->search($producer, Email::TYPE_ORDER_TAKING, $distribution); $emailModule->getBulkMailer()->sendEmail($email, $usersArray); echo 'Email automatique "'.$automaticEmail->getSubject().'" envoyé à '.count($usersArray)." utilisateur(s)\n"; } } } } } ?>