0
我已經檢查了網站上的類似問題,但沒有找到任何東西。我正在發送附件,其中包含表單提交時生成的電子郵件。它在Gmail上運行良好,但在Outlook或我的辦公室郵件服務器上運行良好,電子郵件附帶空白附件。準確地說,這個附件沒有任何數據。電子郵件附件工作在Gmail但不在Outlook或我的郵件服務器上
這裏是我的代碼:
$row = $this->model_catalog_bulk_order_reset->getresetinfotest($orderid)->rows;
$filename= $orderid;
$filename='excel/'.$filename.'.csv';
$fp=fopen($filename,"w");
$seperator="";
foreach($row as $name =>$value)
{
if($name==0){
$seperator="";
$comma="";
foreach($value as $name =>$value)
{
$seperator.=$comma.''.str_replace('','""',$name);
$comma=",";
}
$seperator.="\n";
fputs($fp,$seperator);
}
}
foreach($row as $name =>$value)
{
$seperator="";
$comma="";
foreach($value as $name =>$value)
{
$newValue = explode('-',$value);
$count = count($newValue);
if($count > 1){
$value = $newValue[0]." to ".$newValue[1];
}else{
$value = $newValue[0];
}
$seperator.=$comma.''.str_replace('','""',$value);
$comma=",";
}
$seperator.="\n";
fputs($fp,"'".$seperator);
}
fclose($fp);
$filename= $orderid;
$my_file = $filename.'.csv';
$filename = $filename.'.csv';
$path = "excel/";
$from_name = "XYZ";
$from_mail = $this->config->get('config_email');
$mailto = $customer_record['email'].",".$this->config->get('config_email');
$subject = "Bulk order.";
$body = "Hi,\r\n Please find the attachment?";
$replyto=$this->config->get('config_email');
$file = $path.$my_file;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$name = basename($file);
$eol = PHP_EOL;
$header = "From: ".$from_name." <".$from_mail.">".$eol;
$header .= "Reply-To: ".$replyto.$eol;
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";
$message = "--".$uid.$eol;
$message .= "Content-type:text/plain; charset=iso-8859-1".$eol;
$message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$message .= $body.$eol;
$message .= "--".$uid.$eol;
$message .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol;
$message .= $content.$eol;
$message .= "--".$uid."--";
mail($mailto, $subject, $message, $header);
任何幫助表示讚賞。 謝謝