簡體   English   中英

使用php mail()函數的電子郵件附件-適用於gmail,但對於yahoo,附件的大小為空(0字節)

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

我正在使用php mail()函數發送帶有附件的電子郵件。

它適用於gmail,但yahoo的附件大小為零(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";

我還應該怎么做才能在Yahoo中獲得附件?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM