1 回答
TA贡献1830条经验 获得超3个赞
我刚刚做到了,我粘贴了下面的代码,问题是 php 将新策略应用于新行标题,所以我只需更改一些代码即可避免此限制并解决问题:
<?php
$temp = tmpfile();
fwrite($temp, $ical);
rewind($temp);
$to_email = 'test@gmail.com';
$subject = 'Testing PHP Mail';
$message = 'Hello';
$from_email = 'test@test.com';
$path = stream_get_meta_data($temp)['uri'];
$eol = PHP_EOL;
$filename = "invite.ics";
$mailto = $to_email;
$from_mail = $from_email;
$from_name = "Events";
$replyto = $from_email;
$file = $path;
$file_size = filesize($path);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$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: application/pdf; name=\"".$filename."\"".$eol; // use different content types here
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol;
$message .= $content.$eol;
$message .= "--".$uid."--";
mail($mailto, $subject, $message, $header);
fclose($temp);
?>
- 1 回答
- 0 关注
- 62 浏览
添加回答
举报