Ejemplo n.º 1
0
 /**
  * Email admin
  * @param string $status Message status e.g. error, success, debug
  * @param string $msg Message to email
  * @param boolean $email Email to admin, default false
  * @return boolean
  */
 public static function emailAdmin($status, $msg)
 {
     // Check admin email constants are defined
     if (!defined('EMAIL_FROM')) {
         status::Output('ERROR', 'EMAIL_FROM not specified');
         return;
     }
     if (!defined('AUTHOR_NAME')) {
         status::Output('ERROR', 'AUTHOR_NAME not specified');
         return;
     }
     if (!defined('AUTHOR_EMAIL')) {
         status::Output('ERROR', 'AUTHOR_EMAIL not specified');
         return;
     }
     // Create email
     $email = new Email();
     if (defined('EMAIL_SMTP') && EMAIL_SMTP) {
         $email->setSMTPStream();
     } else {
         $email->setPHPMail();
     }
     // Set message
     $email->addHTML("\n\t\t\t<p>CLI email from " . EMAIL_DOMAIN . ":<br />\n\t\t\tstatus: " . $status . "<br />\n\t\t\tmessage: " . nl2br($msg) . "\n\t\t\t</p>\n\t\t");
     // Send to admin
     $email->addRecipient(AUTHOR_EMAIL, AUTHOR_NAME);
     if ($email->Send(EMAIL_FROM, 'CLI Message') && !\Sonic\Message::count('error')) {
         return TRUE;
     } else {
         return FALSE;
     }
 }