protected function execute(InputInterface $input, OutputInterface $output)
 {
     $limit = $input->getOption('limit');
     $emailsRepository = $this->documentManager->getRepository(Email::REPOSITORY);
     $emails = $emailsRepository->findBy(array('status' => Email::STATUS_TEMPORARY_ERROR), null, $limit);
     foreach ($emails as $email) {
         /* @var $email Email */
         $type = $email->getType();
         $emailAddress = $email->getEmailAddress();
         $arguments = $email->getArguments();
         $this->eventDispatcher->dispatch(EmailEvent::RESEND, new EmailEvent($type, $emailAddress, $arguments));
         $status = $this->communicationService->sendEmail($type, $emailAddress, $arguments);
         $email->setStatus($status);
         $this->documentManager->persist($email);
     }
     $this->documentManager->flush();
 }
 public function onDeliveryEnd(OrderEvent $event)
 {
     $emailAddress = $this->getEmailAddress($event);
     $this->communicationService->sendSatisfactionSurvey($emailAddress, $event->getOrder()->getId());
 }