Beispiel #1
0
 /**
  * @return void
  */
 private function initSmtpTransport()
 {
     $mailConfig = Config::getInstance()->mail;
     if (empty($mailConfig['host']) || $mailConfig['transport'] != 'smtp') {
         return;
     }
     $smtpConfig = array();
     if (!empty($mailConfig['type'])) {
         $smtpConfig['auth'] = strtolower($mailConfig['type']);
     }
     if (!empty($mailConfig['username'])) {
         $smtpConfig['username'] = $mailConfig['username'];
     }
     if (!empty($mailConfig['password'])) {
         $smtpConfig['password'] = $mailConfig['password'];
     }
     if (!empty($mailConfig['encryption'])) {
         $smtpConfig['ssl'] = $mailConfig['encryption'];
     }
     $tr = new \Zend_Mail_Transport_Smtp($mailConfig['host'], $smtpConfig);
     Mail::setDefaultTransport($tr);
     ini_set("smtp_port", $mailConfig['port']);
 }
 private function assertDateInSubject($period, $expectedDate)
 {
     $alerts = $this->getTriggeredAlerts();
     Mail::setDefaultTransport(new \Zend_Mail_Transport_File());
     $mail = new Mail();
     $this->notifier->sendAlertsPerEmailToRecipient($alerts, $mail, '*****@*****.**', $period, 1);
     $expected = 'New alert for website Piwik test [' . $expectedDate . ']';
     $expecteds = array($expected, \Zend_Mime::encodeQuotedPrintableHeader($expected, 'utf-8'));
     $isExpected = in_array($mail->getSubject(), $expecteds);
     $this->assertTrue($isExpected, $mail->getSubject() . " not found in " . var_export($expecteds, true));
 }