Read Attachment

Read the attachment content using the prepareattachment() function

function pepareAttachment( $file , $path ) {
        
    $filename = $path.$file ;
    $file = fopen($filename,"rb");
    $data = fread($file,filesize($filename));
    fclose($file);
    $data = chunk_split(base64_encode($data));
    $attachContent .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$filename\"\n" . 
    "Content-Disposition: attachment;\n" . " filename=\"$filename\"\n" . 
    "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
    $attachContent .= "--{$mime_boundary}\n";

    return $attachContent;
    
}

Share this Tutorial