Exemplo n.º 1
0
 public function Send()
 {
     //
     $log = new EmailLogModel();
     // Подготовляем для логирования
     $log->to = implode(',', $this->originalTo);
     $log->subject = $this->Subject;
     $log->content = $this->originalHtml;
     $log->date = date('Y-m-d H:i');
     //
     debug::disable();
     //
     $result = parent::Send();
     //
     debug::enable();
     //
     if (!$result) {
         $log->status = $this->ErrorInfo;
         $log->insert();
         throw new MailException("Mailer Error: " . $this->ErrorInfo);
     } else {
         $log->insert();
     }
     return $result;
 }
Exemplo n.º 2
0
 public function Send()
 {
     $this->called = true;
     //
     $log = new \EmailLogModel();
     // Подготовляем для логирования
     $log->to = implode(',', $this->originalTo);
     $log->subject = $this->Subject;
     $log->content = $this->originalHtml;
     $log->date = date('Y-m-d H:i');
     $log->insert();
     $this->originalHtml = '';
     $this->originalTo = [];
 }
Exemplo n.º 3
0
 public static function getLast()
 {
     $found = DBSimple::get(\EmailLogModel::getTableName(), '', 'order by id desc');
     if (empty($found)) {
         throw new \NotFoundException('Last log message not found. Log table empty');
     }
     $log = new \EmailLogModel($found);
     return $log;
 }
Exemplo n.º 4
0
 public function testRegistration()
 {
     $schema = \CConfig::getSchema(\UsersRegistration::RegistrationConfirmationConfigName);
     $api = new Registration($this->correctForm);
     $api->exec();
     $this->assertTrue($this->mailer->isSent());
     $lastEmail = \EmailLogModel::getLast();
     $this->assertEquals($lastEmail->to->getValue(), self::SomeCorrectEmail);
     $user = \UserAccount::getByLogin(self::NewLogin);
     $this->assertEquals($user->social_networks->getValue()['facebook'], self::NewUID);
 }
Exemplo n.º 5
0
 public function clear()
 {
     EmailLogModel::deleteAll();
     $this->addAlert('История писем очищена');
     $this->jumpBack();
 }
Exemplo n.º 6
0
 /**
  * Отсылает HTML-письма используя стандартную функцию отсылки писем - mail()
  *
  * @param array $recipients
  * @param string $subject
  * @param string $content
  */
 public static function sendUsingStandartMail($recipients, $subject, $content)
 {
     $log = new EmailLogModel();
     // Подготовляем для логирования
     $log->to = implode(',', $recipients);
     $log->subject = $subject;
     $log->content = $content;
     $log->date = date('Y-m-d H:i');
     $log->insert();
     $register = new SystemRegister('System/email');
     $headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n" . 'From: %s' . "\r\n" . 'X-Mailer: PHP/%s';
     $headers = sprintf($headers, $register->from_email->value, phpversion());
     foreach ($recipients as $to) {
         mail($to, $subject, $content, $headers);
     }
 }