我正在尝试将两个文件附加到电子邮件中,但我不知道为什么我会遇到很多问题。我只需要附加一个文件。怎么办?
这里是代码:
$arquivo = isset($_FILES["fileCURR"]) ? $_FILES["fileCURR"] : FALSE;
$fp = fopen($_FILES["fileCURR"]["tmp_name"],"rb");
$anexo = fread($fp,filesize($_FILES["fileCURR"]["tmp_name"]));
$anexo = base64_encode($anexo);
fclose($fp);
$anexo = chunk_split($anexo);
$boundary = "XYZ-" . date("dmYis") . "-ZYX";
$mens = "--$boundary" . $quebra_linha . "";
$mens .= "Content-Transfer-Encoding: 8bits" . $quebra_linha . "";
$mens .= "Content-Type: text/html; charset=\"ISO-8859-1\"" . $quebra_linha . "" . $quebra_linha . ""; //plain
$mens .= "<strong>E-mail:</strong> $emailt <br> <strong>Website:</strong> $website" . $quebra_linha . "";
$mens .= "--$boundary" . $quebra_linha . "";
$mens .= "Content-Type: ".$arquivo["type"]."" . $quebra_linha . "";
$mens .= "Content-Disposition: attachment; filename=\"".$arquivo["name"]."\"" . $quebra_linha . "";
$mens .= "Content-Transfer-Encoding: base64" . $quebra_linha . "" . $quebra_linha . "";
$mens .= "$anexo" . $quebra_linha . "";
$mens .= "--$boundary--" . $quebra_linha . "";
$headers = "MIME-Version: 1.0" . $quebra_linha . "";
$headers .= "From: $email_from " . $quebra_linha . "";
$headers .= "Return-Path: $email_from " . $quebra_linha . "";
$headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"" . $quebra_linha . "";
$headers .= "$boundary" . $quebra_linha . "";
mail($email,$assunto,$mens,$headers, "-r".$email_from);
echo"Success!";
答案 0 :(得分:1)
老实说,如果你只是将文件链接添加到电子邮件正文,那将会更加简单和容易,因为你已经在表单中上传文件然后存储在你的服务器中,你可以直接链接到电子邮件正文。