示例#1
0
 /**
  * Notify the sys admin via email when a serious error occurs.
  *
  * @param string $message
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\MailNotSentException
  */
 public function notifyAdmin($message)
 {
     $config = ConfigProvider::getInstance();
     // just making sure an email address has been set in the .ini file
     if ($config->get('app.log.error.mail.address') != '') {
         $body = "The following error has occured:\n\n";
         $body .= 'Class:-> ' . $this->classname . "\n\n";
         $body .= 'Message:-> ' . $message . "\n\n";
         $body .= 'Server:-> ' . gethostname() . "\n\n";
         $body .= "\n\nKind regards,\n\nAdministrator\n--\n" . $config->get('app.url');
         $mailer = EmailProviderFactory::getInstance('Alpha\\Util\\Email\\EmailProviderPHP');
         $mailer->send($config->get('app.log.error.mail.address'), $config->get('email.reply.to'), 'Error in class ' . $this->classname . ' on site ' . $config->get('app.title'), $body);
     }
 }
示例#2
0
 /**
  * A generic method for mailing a person.
  *
  * @param string $message
  * @param string $subject
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\MailNotSentException
  */
 public function sendMail($message, $subject)
 {
     $config = ConfigProvider::getInstance();
     $body = '<html><head></head><body><p>Dear ' . $this->getDisplayName() . ',</p>';
     $body .= $message;
     $body .= '</body></html>';
     $mailer = EmailProviderFactory::getInstance('Alpha\\Util\\Email\\EmailProviderPHP');
     $mailer->send($this->get('email'), $config->get('email.reply.to'), $subject, $body, true);
 }