使用php-mail()函数发送电子邮件附件-适用于gmail,但雅虎的附件大小为空(0字节)


Email Attachments using php mail() function - Working for gmail but attachments are of null size (0 bytes) for yahoo

我正在使用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";

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

将/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;