protected static function observe_file2mail($file, $data) { require_once __DIR__ . '/Smekta.php'; $msg = file_get_contents($file); $msg = GN_Smekta::smektuj($msg, $data, false, [__DIR__ . '/../observer']); $body = false; $mail = ['msg' => '', 'header' => '']; foreach (explode("\n", $msg) as $h) { if (!trim($h)) { $body = true; continue; } if ($body) { $mail['msg'] .= "{$h}\n"; } else { $mail['header'] .= "{$h}\n"; $pos = strpos($h, ':'); if ($pos) { $mail[strtolower(substr($h, 0, $pos))] = trim(substr($h, $pos + 1)); } } } return $mail; }