【问题标题】:Email Attachments using php mail() function - Working for gmail but attachments are of null size (0 bytes) for yahoo使用 php mail() 函数的电子邮件附件 - 为 gmail 工作,但雅虎的附件为空大小(0 字节)
【发布时间】:2015-04-28 15:18:58
【问题描述】:

我正在使用 php mail() 函数发送带有附件的电子邮件。

它适用于 gmail,但雅虎的附件大小为空(0 字节)。

这是我使用的附件代码:

                $xMessage .= "Content-type:text/html; charset=iso-8859-1\r\n";
                $xMessage .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $xMessage .= $message."\r\n\r\n";

                $xMessage .= "--".$mime_boundary."\r\n";

                $xMessage .= "Content-Type: application/octet-stream; name=\"".basename("uploads/attachment_file/".$file['attachment_name'])."\"\r\n";

                $xMessage .= "Content-Transfer-Encoding: base64\r\n";

                $xMessage .= "Content-Disposition: attachment; filename=\"".basename("uploads/attachment_file/".$file['attachment_name'])."\"\r\n";

                $content = file_get_contents("uploads/attachment_file/".$file['attachment_name']);

                $xMessage.= chunk_split(base64_encode($content));

                $xMessage .= "\r\n\r\n";

我应该怎么做才能在雅虎中获取附件?

【问题讨论】:

    标签: php email email-attachments ymail


    【解决方案1】:

    把/r/n改成

    $eol = PHP_EOL;
    

    改变

    "Content-Disposition: attachment; filename=\"".basename("uploads/attachment_file/".$file['attachment_name'])."\"\r\n";
    

    "Content-Disposition: attachment; filename=\"".basename("uploads/attachment_file/".$file['attachment_name']).$eol.$eol;
    

    【讨论】:

      猜你喜欢
      • 2019-09-12
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      • 1970-01-01
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多