PDF eki Gmail'de gösterir ancak Outlook açmak için reddediyor

0 Cevap php

Ben php nispeten yeni.

Ben bir işçi için bir kullanıcı ve bir teyidi için bir pdf eki olan bir e-posta gönderen bir senaryo yazdı. Her şey gmail gibi web tabanlı e-posta istemcileri çalışıyor ancak Outlook'ta alındığında pdf eki açmıyor. Ayrıca tamamen boş olduğunu "ATT0159.txt" adı verilen başka bir eki ekler.

İşte kod:

<?php 
$pdf = $_GET['pdf'];
$product = $_GET['product'];

$username = $_POST['Name']; #get name
$useraddress = $_POST['Email']; #get user email address

$subjectUser = $product . " PDF brochure from Specifile on-line";

$to = "specifile@gmail.com"; # recipient
$subject = "Confirmation: PDF Request - " . $product; #subject
$message = "The following person has requested the brochure - " . $product . "\n<br/>" . $username . " [ " . $useraddress . " ] "; #message

$attachment = $_SERVER['DOCUMENT_ROOT'] . "\\" . $pdf;
$attachment_type = "application/pdf";
$attachment_name = "brochure.pdf";

#open, read, then close the file
$fp = fopen( $attachment, 'rb');
$file = fread($fp, filesize($attachment));
fclose($fp);

#create boundary string
$num = md5(time());
$str = "==Multipart_Boundary_x{$num}x";

#encode data for safe transit
$file = chunk_split(base64_encode($file));

#define user header
$headers = "MIME-version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;\r\n";
$headers .= " boundary=\"{$str}\"\r\n";
$headers .= "From: Specifile on-line<specifile@infixion.co.za> \r\n";

#define confirmation header
$Confirmheaders = "MIME-version: 1.0\r\n";
$Confirmheaders .= "Content-type: text/html;";
$Confirmheaders .= " charset=\"UTF-8\"\r\n";
$Confirmheaders .= "From: Specifile on-line<specifile@infixion.co.za> \r\n";

#create message for user
$messageUser = "This is a multi-part message in MIME format\r\n";
$messageUser .= "--{$str}\r\n";
$messageUser .= "Content-type: text/html; charset=\"UTF-8\"\r\n";
$messageUser .= "Content-Transfer-Encoding: 8bit\r\n";
$messageUser .= "Hi " . $username . ", <p>The brochure you requested is attatched.</p> \r\n\n";
$messageUser .= "--{$str}\r\n";

#define non text attachment
$messageUser .= "Content-Type: {$attachment_type}; ";
$messageUser .= "name=\"{$attachment_name}\"\r\n";
$messageUser .= "Content-Disposition: attachment; ";
$messageUser .= "filename=\"{$attachment_name}\"\r\n";
$messageUser .= "Content-Transfer-Encoding: base64\r\n";
$messageUser .= "$file\r\n\n";
$messageUser .= "--{$str}";

mail($useraddress,$subjectUser,$messageUser,$headers);
mail($to,$subject,$message,$Confirmheaders);

?>

0 Cevap