|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67749 Multiple attachments are not coming to sent folder.. Only one is coming
Submitted: 2014-08-02 15:03 UTC Modified: 2015-08-29 12:03 UTC
From: devcoderz at yahoo dot com Assigned: cmb (profile)
Status: Not a bug Package: IMAP related
PHP Version: 5.4.31 OS: Any
Private report: No CVE-ID: None
 [2014-08-02 15:03 UTC] devcoderz at yahoo dot com
From manual page:

I am trying to send an email with multiple attachments. Mail is going fine but in sent folder only one attachment is coming. I am using imap_append() to add it to sent box. There is no relevant documentation on multiple attachments...Please fix this if its a bug otherwise please suggest the solution..

Test script:
if ($mbox=imap_open( $authhost, $user, $pass)) 

            $dmy=date("d-M-Y H:i:s"); 
            $boundary = "------=" . md5(uniqid(rand()));
            $msg .= "From: ".$from[0]."\r\n" 
                . "To: ".$recipients[$key][0]."\r\n" 
                . "CC: ".$ccList."\r\n" 
                . "Date: $dmy\r\n" 
                . "Subject: $subject\r\n"                   
                . "MIME-Version: 1.0\r\n" 
                . "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n" 
                . "\r\n\r\n" 
                . "--$boundary\r\n" 
                . "Content-Type: text/html;\r\n\tcharset=\"ISO-8859-1\"\r\n" 
                . "Content-Transfer-Encoding: 8bit \r\n" 
                . "\r\n\r\n" 
                . $body . "\r\n" 
                . "\r\n\r\n" 
                . "--$boundary\r\n" 
                . "Content-Transfer-Encoding: base64\r\n"; 

                foreach($attachment as $attchURL){
                    $files = $_SERVER['DOCUMENT_ROOT'] . "/attachments/" . $attchURL;
                    $filename = substr($attchURL, strrpos($attchURL,"/")+1);
                    $ouv=fopen ("$files", "rb");$lir=fread ($ouv, filesize ("$files"));
                    $attachments = chunk_split(base64_encode($lir));                        
                    $msg .= "Content-Disposition: attachment; filename=\"$filename\"\r\n" ;                     
                    $msg .=  "\r\n" . $attachments . "\r\n"; 
                $msg .= "\r\n\r\n\r\n" 
                . "--$boundary--\r\n\r\n"; 


Expected result:
It should add multiple attachments to the mail in sent box.

Actual result:
It is only appending one attachment and not the other ones..


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-29 12:03 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-08-29 12:03 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Dec 07 11:01:27 2023 UTC