4

我们的邮件附件有问题。目前我正在为带有附件的 Outlook 日历活动工作。一切都很好,我收到了带有附件的邮件,但只有当附件小于 10Kb 时我才会收到电子邮件。否则我没有收到任何邮件。如果我使用 chunk_split() 功能而不是收到带有超过 10Kb 文件附件的电子邮件,但只收到文件的一部分(我用文本文件测试,我只收到前几行)。

我检查了服务器,它有能力发送大文件。

这是我的代码。请帮帮我。。

if($filename_path ==''){
     $filename_path = './Upload/Cal_temp/'.$filename2;
     $filename_pathnew = base_url().'Upload/Cal_temp/'.$filename2;
}

$calendid = $this->input->post('calendar_id');

$handle = fopen($filename_path, "r");
$contents = fread($handle, filesize($filename_path));
fclose($handle);

$finaldata =  base64_encode($contents);
 $finaldata = chunk_split($finaldata);

$dataone = filesize($filename_path);
$datatwo = strlen($contents); 


define('DATE_ICAL', 'Ymd\THis');
$fromname = 'example';   

$vcal  = "BEGIN:VCALENDAR\n";
$vcal .= "VERSION:2.0\n";
$vcal .= "METHOD:PUBLISH\n"; //requied by Outlook
$vcal .= "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
$vcal .= "BEGIN:VEVENT\n";
/* $vcal .= "STATUS:".$this->input->post('status')."\n"; */
$vcal .= "DTSTART:".date(DATE_ICAL, strtotime($s_date.' '.$s_time))."\n";
$vcal .= "DTEND:".date(DATE_ICAL, strtotime($e_date.' '.$e_time))."\n";
$vcal .= "SUMMARY: ".$desc_txt." ".$empname['firstname'].' '.$empname['lastname']."-".$clientname['firstname'].' '.$clientname['lastname']."\n";
$vcal .= "DESCRIPTION: Your appointment has been updated for ".$empname['firstname'].' '.$empname['lastname']." with ".$clientname['firstname'].' '.$clientname['lastname']." with regard to ".$jobnumber." and ".$taskcode." between ".$s_date.' '.$s_time." and ".$e_date.' '.$e_time."\r\n\r\n";
$vcal .= "ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=".$filename2.":".$finaldata."=\n";

$vcal .= "CLASS:PUBLIC\n";
$vcal .= "TRANSP:OPAQUE\n";
$vcal .= "UID:". $calendid ."\n";
$vcal .= "SEQUENCE:0\n";


$vcal .= "SUMMARY;LANGUAGE=en-us:excel\n";
$vcal .= "X-MICROSOFT-CDO-BUSYSTATUS:BUSY
            X-MICROSOFT-CDO-IMPORTANCE:1
            X-MICROSOFT-DISALLOW-COUNTER:FALSE
            X-MS-OLK-ALLOWEXTERNCHECK:TRUE
            X-MS-OLK-AUTOFILLLOCATION:FALSE
            X-MS-OLK-CONFTYPE:0
            BEGIN:VALARM
            TRIGGER:-PT15M
            ACTION:DISPLAY
            DESCRIPTION:Reminder
            END:VALARM
            END:VEVENT
            END:VCALENDAR";


$headers = "From: ".$fromemail."\r\nReply-To: "; 
$headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; method=REQUEST; charset=\"utf-8\"";
$headers .= "\r\n Content-Transfer-Encoding: base64\r\nX-Mailer: Microsoft Office Outlook 12.0"; 
//$headers .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$subject = 'Your appointment has been updated';

mail($email, $subject, $vcal, $headers);

我尝试了几乎所有类型的标题,但没有运气。

4

1 回答 1

0

也许标题前面的空间可能是问题

-$headers .="\r\n Content-Transfer-Encoding:...
+$headers .="\r\nContent-Transfer-Encoding:...
于 2014-09-19T00:17:39.047 回答