Example #1
0
 public function testSetMailConfigBadToAddress()
 {
     $object = new \Foundation\Configuration();
     $address = uniqid() . 'bad';
     $this->setExpectedException('\\Foundation\\Exception', "{$address} is not a valid email address");
     $object->setMailOverrideToAddress($address);
 }
Example #2
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $this->_config = new \Jazzee\Configuration();
     $foundationConfig = new \Foundation\Configuration();
     $foundationConfig->setCacheType('array');
     $foundationConfig->setMailSubjectPrefix($this->_config->getMailSubjectPrefix());
     $foundationConfig->setMailDefaultFromAddress($this->_config->getMailDefaultFromAddress());
     $foundationConfig->setMailDefaultFromName($this->_config->getMailDefaultFromName());
     $foundationConfig->setMailOverrideToAddress($this->_config->getMailOverrideToAddress());
     $foundationConfig->setMailServerType($this->_config->getMailServerType());
     $foundationConfig->setMailServerHost($this->_config->getMailServeHost());
     $foundationConfig->setMailServerPort($this->_config->getMailServerPort());
     $foundationConfig->setMailServerUsername($this->_config->getMailServerUsername());
     $foundationConfig->setMailServerPassword($this->_config->getMailServerPassword());
     $entityManager = $this->getHelper('em')->getEntityManager();
     $body = '';
     $from = new \DateTime($input->getOption('from'));
     $to = new \DateTime($input->getOption('to'));
     if ($input->getOption('error-log')) {
         $messages = $this->parseErrorLog($from, $to);
         $body .= '<h4>Error Log</h4><p>There were ' . count($messages) . ' errors between ' . $from->format(self::DATE_FORMAT) . ' and ' . $to->format(self::DATE_FORMAT) . '</p>';
         $body .= $this->formatString($messages);
     }
     if ($input->getOption('access-log')) {
         $messages = $this->parseAccessLog($from, $to);
         $body .= '<h4>Access Log ' . $from->format(self::DATE_FORMAT) . ' to ' . $to->format(self::DATE_FORMAT) . '</h4>';
         $body .= $this->formatString($messages);
     }
     $message = new \Foundation\Mail\Message($foundationConfig);
     $message->IsHTML();
     $message->AddAddress($input->getArgument('email'));
     $message->Subject = 'Jazzee Log Summary';
     $message->Body = $body;
     $message->Send();
     $output->write("<info>Log Summary sent to {$input->getArgument('email')}.</info>" . PHP_EOL);
 }