这是我发送 pdf 文件的php代码,其中包含电子邮件中的附件。现在我有关于outlook和hotmail附件的问题。如果我发送电子邮件(pdf文件附件大小为2 mb),它会向我显示损坏的文件(在outlook和hotmai中)并以一些 348字节显示文件。
但在 gmail,yahoo邮件和其他邮件中工作正常。
这是我的php电子邮件附件代码
$seller_name = "seller name";
$file_name = "po2181492084075.pdf";
// test eamil
$seller_email_id = "someemail@outlook.com";
//$seller_email_id = "dsomedata@gmail.com";
$file_name = $file_name;
$path = "agreementpdf";
$mailto = $seller_email_id;
$subject = "Notification of order";
$bodytext = "Hello ".$seller_name.",\nThis Order has been sent to the Seller . You will be notified when their review has been completed.\n Regard \n onlinecode Team";
$file = $path . "/" . $file_name;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
// a random hash will be necessary to send mixed content
$separator = md5(time());
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
$message = $bodytext;
// main header (multipart mandatory)
$headers = "From: Team <contact@onlinecode.org>" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol;
// message
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol;
$headers .= "Content-Transfer-Encoding: 8bit" . $eol;
$headers .= $message . $eol;
// attachment
$headers .= "--" . $separator . $eol;
$headers .= "Content-Type: application/octet-stream; name=\"" . $file_name . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: base64" . $eol;
$headers .= "Content-Disposition: attachment" . $eol;
$headers .= $content . $eol;
$headers .= "--" . $separator . "--";
// sleep for create eamil header
sleep(3);
//SEND Mail
$eamil = mail($mailto, $subject, "onlinecode", $headers);
echo $eamil;
我不知道什么是问题,以及如何解决它,任何建议都将不胜感激