protected function send_raw()
 {
     if (!SEmail::validate_email($this->from_email)) {
         return 'Invalid "From" email';
     }
     if (!SEmail::validate_email($this->to)) {
         return 'Invalid "To" email';
     }
     $from = $this->make_from();
     $hdr = 'From: ' . $from . "\r\n";
     $hdr .= 'Return-Path: ' . $this->from_email . "\r\n";
     $hdr .= 'Errors-To: ' . $this->from_email . "\r\n";
     if ($this->html_email) {
         $hdr .= "MIME-Version: 1.0\r\n";
     }
     foreach ($this->headers as $key => $val) {
         $hdr .= $this->santize_string($key) . ': ' . $this->santize_string($val) . "\r\n";
     }
     if (!count($this->attachments)) {
         if ($this->html_email) {
             $hdr .= 'Content-Type: text/html; charset=' . $this->charset . "\r\n";
         }
         $body = $this->body;
     } else {
         $str = $this->body;
         foreach ($this->attachments as $att) {
             $str .= $att->content;
         }
         $boundary = $this->generate_boundary($str);
         $hdr .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . "\r\n";
         $attachs = '';
         foreach ($this->attachments as $att) {
             if (strpos($att->mime_type, '/') === false) {
                 throw new Exception('Invalid MIME type of the attachment.');
             }
             $attachs .= "--{$boundary}\r\n";
             $attachs .= 'Content-Type: ' . $att->mime_type;
             if ($att->content_name != '') {
                 $attachs .= '; name="' . $att->content_name . '"';
             }
             $attachs .= "\r\n";
             $attachs .= "Content-Transfer-Encoding: base64\r\n";
             if ($att->file_name != '') {
                 $attachs .= 'Content-Disposition: attachment; filename="' . $att->file_name . '"' . "\r\n";
             }
             if ($att->content_id != '') {
                 $attachs .= 'Content-ID: <' . $att->content_id . ">\r\n";
             }
             $attachs .= "\r\n";
             $attachs .= chunk_split(base64_encode($att->content)) . "\r\n";
         }
         $body = "--{$boundary}\r\n";
         $body .= "Content-type: text/html; charset=" . $this->charset . "\r\n\r\n";
         $body .= $this->body . "\r\n" . $attachs;
         $body .= "--{$boundary}--\r\n";
     }
     if (DEBUG) {
         $msg = "**SendMail to \"{$this->to}\" with subject \"{$this->subject}\"**";
         if (!conf('mail.send')) {
             $msg .= ' !!(Sending email is disabled)!!';
         }
         dwrite($msg);
         dwrite_msg('Headers', $hdr);
         dwrite_msg('Body', $body);
     }
     if (conf('mail.send')) {
         switch (conf('mail.type')) {
             case 'mail':
                 return $this->send_mail_mail($from, $this->to, $this->subject, $hdr, $body);
             case 'smtp':
                 return $this->send_mail_smtp($this->from_email, $from, $this->to, $this->subject, $hdr, $body);
             case 'sendmail':
                 return $this->send_mail_sendmail($from, $this->to, $this->subject, $hdr, $body);
             default:
                 throw new Exception('Unknown mailer type (' . conf('mail.type') . ')');
         }
     }
     return '';
 }
 function __construct()
 {
     $this->_start_time = get_microtime();
     if (DEBUG) {
         dwrite("**[Page processing begin]**");
         if (conf('page.show_vars', false)) {
             dwrite_msg('GET', dump_str($_GET));
             dwrite_msg('POST', dump_str($_POST));
             dwrite_msg('SESSION', dump_str($_SESSION));
             dwrite_msg('FILES', dump_str($_FILES));
             dwrite_msg('COOKIE', dump_str($_COOKIE));
         }
     }
     $this->fill_templates_paths();
 }