【发布时间】:2020-11-27 14:48:32
【问题描述】:
当我使用 mail() 函数发送文件时,我正在尝试设置文件的名称,我发送它但在 gmail 中我收到的是没有扩展名的无名文件。
谁能帮帮我?
<?php
$temp = tmpfile();
fwrite($temp, $ical);
rewind($temp);
$to_email = 'test@gmail.com';
$subject = 'Testing PHP Mail';
$message = 'Hola caracola';
$from_email = 'test@test.com';
$path = stream_get_meta_data($temp)['uri'];
$num = md5(time());
$headers = "MIME-Version: 1.0\r\n"; // Defining the MIME version
$headers .= "From:".$from_email."\r\n"; // Sender Email
$headers .= "Reply-To: ".$from_email."\r\n"; // Email addrress to reach back
$headers .= "Content-Type: multipart/mixed;\r\n"; // Defining Content-Type
$body ="Content-Type: text/calendar; name=invite.ics\r\n";
$body .="Content-Disposition: attachment; filename=\"invite.ics\"\r\n";
$body .= $content; // Attaching the encoded file with email
mail($to_email,$subject,$body,$headers);
fclose($temp);
} ?>
谢谢
【问题讨论】:
-
text/invite.ics不是有效的 mime 类型 -
@jrswgtr 哪个是 ics 文件的有效类型?
-
这并不能解决问题,但谢谢
-
是的,我没有说它会解决你的问题,但我看到了,我想我不妨对你说;-)
标签: php laravel email attachment