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;
    }
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;
    }
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 ; }
Attaches a saved file.

@param $file any valid path to a file
@param $type valid mime type. e.g.:
audio/mpeg
image/jpeg
application/zip
audio/wav
etc.
@param $name optional, sets the filename for message
@param $asstring if set to true, $file contains contents, not filename
Attaches a saved file .