PHP Classes

Alternate Attachment Function

Recommend this page to a friend!

      simple Email Class  >  All threads  >  Alternate Attachment Function  >  (Un) Subscribe thread alerts  
Subject:Alternate Attachment Function
Summary:This function lets you specify an alternate filename
Messages:1
Author:JImmy Bo
Date:2011-12-14 17:51:59
 

  1. Alternate Attachment Function   Reply   Report abuse  
Picture of JImmy Bo JImmy Bo - 2011-12-14 17:51:59
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