示例#1
0
文件: Mailer.php 项目: acp3/core
 /**
  * Sends the email
  *
  * @return bool
  */
 public function send()
 {
     try {
         $this->configure();
         $this->phpMailer->Subject = $this->generateSubject();
         if (is_array($this->from) === true) {
             $this->phpMailer->setFrom($this->from['email'], $this->from['name']);
         } else {
             $this->phpMailer->setFrom($this->from);
         }
         $this->generateBody();
         // Add attachments to the E-mail
         if (count($this->attachments) > 0) {
             foreach ($this->attachments as $attachment) {
                 if (!empty($attachment) && is_file($attachment)) {
                     $this->phpMailer->addAttachment($attachment);
                 }
             }
         }
         if (!empty($this->recipients)) {
             return $this->bcc === true ? $this->sendBcc() : $this->sendTo();
         }
     } catch (\phpmailerException $e) {
         $this->logger->error('mailer', $e);
     } catch (\Exception $e) {
         $this->logger->error('mailer', $e);
     }
     return false;
 }
示例#2
0
文件: Connection.php 项目: acp3/core
 /**
  * @param callable $callback
  *
  * @return bool|int
  * @throws \Doctrine\DBAL\ConnectionException
  */
 public function executeTransactionalQuery(callable $callback)
 {
     $this->connection->beginTransaction();
     try {
         $result = $callback();
         $this->connection->commit();
     } catch (\Exception $e) {
         $this->connection->rollBack();
         $this->logger->error('database', $e);
         $result = false;
     }
     return $result;
 }
示例#3
0
 /**
  * @param \Exception $e
  */
 public function handleException($e)
 {
     $this->logger->error('exception', $e);
     exit(255);
 }