Exemplo n.º 1
0
 /**
  * @dataProvider dataProviderTestParser
  */
 public function testParser($expectedBounce, $expectedAuthCode, $message, $filename)
 {
     $emailSource = file_get_contents($filename);
     $parser = new EmailParser();
     $parser->parse($emailSource);
     $this->assertSame($expectedBounce, $parser->getBounceLevel(), 'Bounce level should be ' . var_export($expectedBounce, true) . ' for ' . $message);
     $this->assertSame($expectedAuthCode, $parser->getAuthCode(), 'AuthCode should be ' . var_export($expectedAuthCode, true) . ' for ' . $message);
 }
Exemplo n.º 2
0
 /**
  * Dispatch actions to take according to current bounce level
  */
 public function dispatch()
 {
     $this->findEmail();
     // If couldn't find the original email we cannot do anything
     if (!$this->email) {
         Tools::getLogger(__CLASS__)->warning('Bounced email found but cannot find corresponding record in database. Skipped.');
         return;
     }
     $bounceLevel = $this->emailParser->getBounceLevel();
     if ($bounceLevel != EmailParser::NEWSLETTER_NOT_A_BOUNCE) {
         if ($this->recipientList) {
             $this->recipientList->registerBounce($this->email->getRecipientAddress(), $bounceLevel);
         }
         $this->email->setBounceTime(new DateTime());
         $emailRepository = $this->objectManager->get(\Ecodev\Newsletter\Domain\Repository\EmailRepository::class);
         $emailRepository->updateNow($this->email);
     }
     Tools::getLogger(__CLASS__)->info('Bounced email found with bounce level ' . $bounceLevel);
 }