public function attachFile($file, $type, $name = null, $asstring = false)
    {
        $content = $asstring ? $file : file_get_contents($file);
        if (!$content) {
            throw new Exception_TMail('Error reading attachment: '.($asstring ? $name : $file));
        }
        if (is_null($name)) {
            if ($asstring) {
                $name = 'file_'.count($this->mime);
            } else {
                $name = basename($file);
            }
        }
        // encoding content
        $this->mime['"'.$name.'"'] = array(
                'type' => $type,
                'content' => base64_encode($content),
                'attachment' => true,
                );

        return $this;
    }