src/Component/Mail/Mailer.php
private function parseAttachments(array $files, string $message, string $contentType, string $hash) : string
    {
        $result = [];

        // The original message
        $result[] = '--body-mixed-' . $hash;
        $result[] = new Header('Content-Type', $contentType);
        $result[] = '';
        $result[] = $message;

        // The attachments
        foreach ($files as $file) {

            $headers = new Headers();
            $headers->add(new Header('Content-Transfer-Encoding', 'base64'));
            $headers->add(new Header('Content-Disposition', 'attachment'));
            $headers->add(new Header('Content-Type', 'application/octet-stream', [
                'filename' => $file->getFilename()
            ]));

            $result[] = '--body-mixed-' . $hash;
            $result[] = $headers;
            $result[] = '';
            $result[] = base64_encode($file->fread($file->getSize()));
        }

        return implode("\r\n", $result);
    }
private function parseAttachments(array $files, string $message, string $contentType, string $hash) : string
    {
        $result = [];

        // The original message
        $result[] = '--body-mixed-' . $hash;
        $result[] = new Header('Content-Type', $contentType);
        $result[] = '';
        $result[] = $message;

        // The attachments
        foreach ($files as $file) {

            $headers = new Headers();
            $headers->add(new Header('Content-Transfer-Encoding', 'base64'));
            $headers->add(new Header('Content-Disposition', 'attachment'));
            $headers->add(new Header('Content-Type', 'application/octet-stream', [
                'filename' => $file->getFilename()
            ]));

            $result[] = '--body-mixed-' . $hash;
            $result[] = $headers;
            $result[] = '';
            $result[] = base64_encode($file->fread($file->getSize()));
        }

        return implode("\r\n", $result);
    }
private function parseAttachments ( array $ files , string $ message , string $ contentType , string $ hash ) : string { $ result = [ ] ; // The original message $ result [ ] = '--body-mixed-' . $ hash ; $ result [ ] = new Header ( 'Content-Type' , $ contentType ) ; $ result [ ] = '' ; $ result [ ] = $ message ; // The attachments foreach ( $ files as $ file ) { $ headers = new Headers ( ) ; $ headers -> add ( new Header ( 'Content-Transfer-Encoding' , 'base64' ) ) ; $ headers -> add ( new Header ( 'Content-Disposition' , 'attachment' ) ) ; $ headers -> add ( new Header ( 'Content-Type' , 'application/octet-stream' , [ 'filename' => $ file -> getFilename ( ) ] ) ) ; $ result [ ] = '--body-mixed-' . $ hash ; $ result [ ] = $ headers ; $ result [ ] = '' ; $ result [ ] = base64_encode ( $ file -> fread ( $ file -> getSize ( ) ) ) ; } return implode ( "\r\n" , $ result ) ; }
This will return a message body with the attachments in
basecode64 encoding also the original message will be included

@param SplFileObject[] $files
@param string          $message
@param string          $contentType
@param string          $hash

@return string
This will return a message body with the attachments in basecode64 encoding also the original message will be included