function attachment($file, $newfname='') {
if(is_file($file)) {
$basename = basename($file);
if(@empty($newfname))
$newfname = $basename;
$attachmentheader = "--{$this->emailboundary}\r\n";
$attachmentheader .= "Content-Type: ".$this->mime_type($file)."; name=\"{$newfname}\"\r\n";
$attachmentheader .= "Content-Transfer-Encoding: base64\r\n";
$attachmentheader .= "Content-Disposition: attachment; filename=\"{$newfname}\"\r\n\r\n";
$attachmentheader .= chunk_split(base64_encode(fread(fopen($file,"rb"),filesize($file))),72)."\r\n";
$this->attachment[] = $attachmentheader;
} else {
die('The File '.$file.' does not exsist.');
}
}
pastebin.com/cZ9WmWRZ