php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: devcoderz at yahoo dot com
New email:
PHP Version: OS:

 

 [2014-08-02 15:03 UTC] devcoderz at yahoo dot com
Description:
------------
---
From manual page: http://www.php.net/function.imap-append
---

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"));
                    fclose($ouv);
                    $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"; 

            imap_append($mbox,$authhost,($msg)); 
            imap_close($mbox); 
        }   

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..

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-29 12:03 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-08-29 12:03 UTC] cmb@php.net
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 http://www.php.net/support.php 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-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 13:03:35 2021 UTC