我正在尝试使用邮件发送带有PDF附件的HTML电子邮件,但我收到此错误:
警告:mail():找到多个或格式错误的换行符 第69行的文件名中的additional_header
是否可以通过这种方式发送附件:
$file = "New CV - small.pdf";
$file_size = filesize($file);
$filename = "My CV";
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$uid = md5(uniqid(time()));
$content = chunk_split(base64_encode($content));
$email = format_email ($name, $company['name'], $ending, false, $link);
$headers = "From: Paul Ledger <route1designs@hotmail.co.uk>\r\n";
$headers .= "Reply-To: route1designs@hotmail.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$headers .= $subject."\r\n";
$headers .= "--".$uid."\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$headers .= "--".$uid."\r\n";
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
$headers .= $content."\r\n\r\n";
$headers .= "--".$uid."--";
mail($email_to, $subject, $email, $headers);