Пример #1
0
 /**
  * Sends email with settings
  *
  * Send Email with settings for $this->_mailbox.
  * If cc is set When additional email is set, then it sends additional emails to cc.
  * If password is set, then password is shown in email.
  * if isWelcome is set to true, adding welcome subject and welcome text to email.
  *
  * @param bool $cc Additional email.
  * @param string $password Password to send for mailbox owner
  * @param bool $isWelcome Defines email is welcome email or not.
  * @return bool
  */
 private function _sendSettingsEmail($cc = false, $password = '', $isWelcome = false, $email = false)
 {
     $mailer = $this->getMailer();
     if ($isWelcome) {
         $mailer->setSubject(sprintf(_("Welcome to your new mailbox on %s"), $this->getMailbox()->getDomain()->getDomain()));
     } else {
         $mailer->setSubject(sprintf(_("Settings for your mailbox on %s"), $this->getMailbox()->getDomain()->getDomain()));
     }
     $mailer->setFrom($this->_options['server']['email']['address'], $this->_options['server']['email']['name']);
     if (!$email) {
         $mailer->addTo($this->getMailbox()->getUsername(), $this->getMailbox()->getName());
     } else {
         $mailer->addTo($email);
     }
     if ($cc) {
         $mailer->addCc($cc);
     }
     $this->view->mailbox = $this->getMailbox();
     $this->view->welcome = $isWelcome;
     $this->view->password = $password;
     $settings = $this->_options['server'];
     foreach ($settings as $tech => $params) {
         foreach ($params as $k => $v) {
             $settings[$tech][$k] = \Entities\Mailbox::substitute($this->getMailbox()->getUsername(), $v);
         }
     }
     $this->view->settings = $settings;
     $this->notify('mailbox', 'sendSettingsEmail', 'preSetBody', $this);
     $mailer->setBodyText($this->view->render('mailbox/email/settings.phtml'));
     try {
         $mailer->send();
     } catch (Exception $e) {
         return false;
     }
     return true;
 }