Advertisement
Guest User

alternate attachment function

a guest
Dec 14th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1.     function attachment($file, $newfname='') {
  2.         if(is_file($file)) {
  3.             $basename = basename($file);
  4.            
  5.             if(@empty($newfname))
  6.                 $newfname = $basename;
  7.                
  8.             $attachmentheader = "--{$this->emailboundary}\r\n";
  9.             $attachmentheader .= "Content-Type: ".$this->mime_type($file)."; name=\"{$newfname}\"\r\n";
  10.             $attachmentheader .= "Content-Transfer-Encoding: base64\r\n";
  11.             $attachmentheader .= "Content-Disposition: attachment; filename=\"{$newfname}\"\r\n\r\n";
  12.             $attachmentheader .= chunk_split(base64_encode(fread(fopen($file,"rb"),filesize($file))),72)."\r\n";
  13.            
  14.             $this->attachment[] = $attachmentheader;
  15.         } else {
  16.             die('The File '.$file.' does not exsist.');
  17.         }
  18.     }
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement