/**
  * Send e-mail report if system detected that e-mail should be sent
  * 
  * @return boolean|null true if mail was sent and null if mail shouldn't be sent
  */
 protected function sendEmailReport()
 {
     if ($this->emailReport === true && $this->config['email'] !== null) {
         $body = implode('', $this->messages);
         /* this doesn't have sense any more :::
         			$body .= "\n\n---------- debug_backtrace:\n";
         
         			foreach (debug_backtrace() as $r) {
         				if (isset($r['file']) && isset($r['line'])) {
         					$body .= "{$r['file']}:{$r['line']} ";
         				}
         
         				if (isset($r['function'])) {
         					$body .= "{$r['function']} ";
         				}
         
         				if (isset($r['args'])) {
         					$body .= implode(', ', $r['args']);
         				}
         
         				$body .= "\n";
         			}
         			*/
         $body .= "\n----------\n";
         $body .= sprintf("server: %s (%s)\n", Request::serverIp(), Request::hostName());
         if (PHP_SAPI != 'cli') {
             $body .= 'URI: ' . $_SERVER['REQUEST_METHOD'] . '=' . Application::getConfig('application', 'site_url') . Application::getUri() . "\n";
             $body .= sprintf("User IP: %s (%s)%s", Request::ip(), Request::host(), Request::hasProxy() ? sprintf(" via %s for %s\n", Request::proxySignature(), Request::httpXForwardedFor()) : "\n");
             $body .= sprintf("UAS: %s\n", isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'no user agent set');
         } else {
             $body .= 'CLI Name: ' . Application::getCliName() . "\n";
             $body .= 'CLI Script: ' . Application::getCliScript() . "\n";
             $params = Cli::getParameters();
             if (count($params) > 0) {
                 $body .= 'CLI Params: ' . print_r($params, true) . "\n";
             }
         }
         $body .= sprintf("Server load: %s\n", Server::getServerLoad());
         $peak = memory_get_peak_usage(true);
         $memoryLimit = ini_get('memory_limit');
         $body .= sprintf("Memory: %s; peak: %s; limit: %s; spent: %s%%\n", Convert::bytesToString(memory_get_usage(true)), Convert::bytesToString($peak), $memoryLimit, $memoryLimit !== false && $memoryLimit > 0 ? round($peak * 100 / Convert::stringToBytes($memoryLimit), 2) : 'null');
         $body .= sprintf("included files: %s\n", print_r(get_included_files(), true));
         $mail = Mail::create();
         $mail->from('alert@' . Request::hostName(), Request::hostName())->subject('Log report')->body($body);
         if (!is_array($this->config['email']) && strpos($this->config['email'], ',') !== false) {
             $this->config['email'] = explode(',', $this->config['email']);
         }
         if (is_array($this->config['email'])) {
             foreach ($this->config['email'] as $toEmail) {
                 $mail->to(trim($toEmail));
             }
         } else {
             $mail->to(trim($this->config['email']));
         }
         if (!$mail->send()) {
             $this->error("Can not send alert mail to {$this->config['email']}: {$mail->getError()}\n{$mail->getException()->getTraceAsString()}");
             return false;
         }
         return true;
     }
     return null;
 }