duanbimo7212 2014-09-04 19:53
浏览 138

带邮件的多个文件附件()

I'm trying to attach TWO files to an email, but I don't know why I'm getting a lot of problems. I need just more one file attached. What to do?

Here the code:

$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!";
  • 写回答

1条回答 默认 最新

  • duan111112 2014-09-04 19:59
    关注

    To be honest, it would be way more simple and easy if you just add the file links to the email body, since you have uploaded the files in a form and stored then in you server, you can just link then in the email body.

    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计