2010-07-07 68 views

回答

0

發送PDF文件只是設置MIME類型和類似的東西。我有一些示例代碼,你可以看看,你如何可以做到這一點。

$trenner = md5(uniqid(time())); 
$params = array(); 
$params['content_type'] = "multipart/mixed; boundary=$trenner"; 
$params['subject'] = $subject; 
$params['body'] = "\n--$trenner\n"; 
$params['body'] .= "Content-Type: text/plain; charset=UTF-8; format=flowed;"."\n\n"; // sets the mime type 
$params['body'] .= $message . "\n"; // Message goes here 
$params['body'] .= "\n\n"; 
$params['body'] .= "\n\n"; 

$dir = file_directory_path().'/'; 
$pdffile = $dir.$pdffile_name; 
$pdffile_mime = file_get_mimetype($pdffile); 

$params['body'] .= "--$trenner"."\n"; 
$params['body'] .= "Content-Type:$pdffile_mime; name='$pdffile_name'\n"; 
$params['body'] .= "Content-Disposition: attachment; filename=$pdffile_name\n"; 
$params['body'] .= "Content-Transfer-Encoding: base64\n\n"; 
$params['body'] .= chunk_split(base64_encode($filedata)); 
$params['body'] .= "--$trenner--"; 
相關問題