public function getBody()
    {
        // first we should render the body if it was not rendered before
        if (is_null($this->body)) {
            $this->set('body', '');
            // this is unnormal situation, notifying developer
            $this->app->logger->logLine('Email body is null: '.$this->get('from').' >> '.
                    date($this->app->getConfig('locale/timestamp', 'Y-m-d H:i:s')."\n"), null, 'error');
        }
        //if(!isset($this->mime['text'])&&!isset($this->mime['html'])){
        $this->setBody(is_object($this->body) ? $this->body->render() : $this->body);
        //}
        // sign should be added to all parts
        if (isset($this->mime['text'])) {
            $this->mime['text']['content'] .= $this->getSign();
        }
        if (isset($this->mime['html'])) {
            $this->mime['html']['content'] .= $this->getSign();
            // HTML should be converted to base 64
            //$this->mime['html']['content']=base64_encode($this->mime['html']['content']);
            // no, it should be splitted
            //$this->mime['html']['content']=wordwrap($this->mime['html']['content'],76,"\r\n",false);
        }
        // now as we have all the needed parts set
        $result = '';
        // first we have to add a simple text for non-Mime readers
        if (count($this->mime) == 0) {
            $result .= $this->plain_text;
        }
        // adding mail parts
        foreach ($this->mime as $name => $att) {
            list($type) = explode(';', $att['type']);
            // $name is a file name/part name, $att is a hash with type and content
            // depending on the type adding a header
            switch ($type) {
                case 'text/plain':
                    if (count($this->mime) > 0) {
                        $result .= "\n\n--".$this->getBoundary()."\n".
                        'Content-Type: '.$att['type'].'; ';
                    }
                    //$result.="charset=UTF-8";
                    break;

                case 'text/html':
                    if (count($this->mime) > 0) {
                        $result .= "\n\n--".$this->getBoundary()."\n".
                        'Content-Type: '.$att['type'].'; ';
                    }
                    $result .=
                        'Content-Transfer-Encoding: 8bit';
                    $att['content'] = rtrim(wordwrap($att['content']));
                    break;
            }
            if (isset($att['attachment'])) {
                $att['content'] = rtrim(chunk_split($att['content']));
                $result .= "name=$name\n".
                    "Content-transfer-encoding: base64\nContent-Disposition: attachment;";
            }
            $result .= "\n\n";
            $result .= $att['content'];
        }
        // if there were any attachments, trailing boundary should be added
        if (count($this->mime) > 0) {
            $result .= "\n--".$this->getBoundary()."\n";
        }

        return ltrim($result);
    }