dongzhengzhong1282 2016-06-14 11:20
浏览 41

PHP发送附件被破坏的邮件

I have a simple script in PHP and FPDI : https://www.setasign.com/products/fpdi/downloads/

So I manually create a PDF and after that I'm trying to send it in email :

        $headers = "From: xxxxxxxxxxxx <".$from.">".$eol;
        $headers .= "MIME-Version: 1.0
";
        $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
        $message = "--".$separator.$eol;
        $message .= "Content-Type: text/html; charset=ISO-8859-1".$eol;
        $message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
        $message .= $body.$eol;
        $message .= "--".$separator.$eol;
        $message .= "Content-Type: application/pdf; name=\"".$filename."\"".$eol;
        $message .= "Content-Transfer-Encoding: base64".$eol;
        $message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol;
        $message .= $attachment.$eol;
        $message .= "--".$separator."--";

        // send message
        mail($to, "subject", $message, $headers);

When I try to send this email to my gmail account, it's ok, I receive email + pdf.

But if I try to send to a custom email and if I check on Thunderbird for example, my pdf is corrupted, and I get an error like : "This attachment is empty, please check the sender. Firewall or antivirus can destroy attachment"

Any ideas ? What's the problem ? My sender email ? My PHP script ? Other ?

Thanks !

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题