protected function getSectionAttachments()
    {
        $output = '';

        foreach ($this->_attachments as $key => $file) {
            $tmp_file = false;

            // If the attachment is a URL, download the file to a temporary location.
            // This prevents downloading the file twice - once for info, once for data.
            if (filter_var($file['file'], FILTER_VALIDATE_URL)) {
                $gateway = new Gateway();
                $gateway->init($file['file']);
                $gateway->setopt('TIMEOUT', 30);
                $file_content = @$gateway->exec();

                $tmp_file = tempnam(TMP, 'attachment');
                General::writeFile($tmp_file, $file_content, Symphony::Configuration()->get('write_mode', 'file'));

                $original_filename = $file['file'];
                $file['file'] = $tmp_file;

                // Without this the temporary filename will be used. Ugly!
                if (is_null($file['filename'])) {
                    $file['filename'] = basename($original_filename);
                }
            } else {
                $file_content = @file_get_contents($file['file']);
            }

            if ($file_content !== false && !empty($file_content)) {
                $output .= $this->boundaryDelimiterLine('multipart/mixed')
                     . $this->contentInfoString($file['mime-type'], $file['file'], $file['filename'], $file['charset'])
                     . EmailHelper::base64ContentTransferEncode($file_content);
            } else {
                if ($this->_validate_attachment_errors) {
                    if (!$tmp_file === false) {
                        $filename = $original_filename;
                    } else {
                        $filename = $file['file'];
                    }

                    throw new EmailGatewayException(__('The content of the file `%s` could not be loaded.', array($filename)));
                }
            }

            if (!$tmp_file === false) {
                General::deleteFile($tmp_file);
            }
        }
        return $output;
    }
protected function getSectionAttachments()
    {
        $output = '';

        foreach ($this->_attachments as $key => $file) {
            $tmp_file = false;

            // If the attachment is a URL, download the file to a temporary location.
            // This prevents downloading the file twice - once for info, once for data.
            if (filter_var($file['file'], FILTER_VALIDATE_URL)) {
                $gateway = new Gateway();
                $gateway->init($file['file']);
                $gateway->setopt('TIMEOUT', 30);
                $file_content = @$gateway->exec();

                $tmp_file = tempnam(TMP, 'attachment');
                General::writeFile($tmp_file, $file_content, Symphony::Configuration()->get('write_mode', 'file'));

                $original_filename = $file['file'];
                $file['file'] = $tmp_file;

                // Without this the temporary filename will be used. Ugly!
                if (is_null($file['filename'])) {
                    $file['filename'] = basename($original_filename);
                }
            } else {
                $file_content = @file_get_contents($file['file']);
            }

            if ($file_content !== false && !empty($file_content)) {
                $output .= $this->boundaryDelimiterLine('multipart/mixed')
                     . $this->contentInfoString($file['mime-type'], $file['file'], $file['filename'], $file['charset'])
                     . EmailHelper::base64ContentTransferEncode($file_content);
            } else {
                if ($this->_validate_attachment_errors) {
                    if (!$tmp_file === false) {
                        $filename = $original_filename;
                    } else {
                        $filename = $file['file'];
                    }

                    throw new EmailGatewayException(__('The content of the file `%s` could not be loaded.', array($filename)));
                }
            }

            if (!$tmp_file === false) {
                General::deleteFile($tmp_file);
            }
        }
        return $output;
    }
protected function getSectionAttachments ( ) { $ output = '' ; foreach ( $ this -> _attachments as $ key => $ file ) { $ tmp_file = false ; // If the attachment is a URL, download the file to a temporary location. // This prevents downloading the file twice - once for info, once for data. if ( filter_var ( $ file [ 'file' ] , FILTER_VALIDATE_URL ) ) { $ gateway = new Gateway ( ) ; $ gateway -> init ( $ file [ 'file' ] ) ; $ gateway -> setopt ( 'TIMEOUT' , 30 ) ; $ file_content = @ $ gateway -> exec ( ) ; $ tmp_file = tempnam ( TMP , 'attachment' ) ; General :: writeFile ( $ tmp_file , $ file_content , Symphony :: Configuration ( ) -> get ( 'write_mode' , 'file' ) ) ; $ original_filename = $ file [ 'file' ] ; $ file [ 'file' ] = $ tmp_file ; // Without this the temporary filename will be used. Ugly! if ( is_null ( $ file [ 'filename' ] ) ) { $ file [ 'filename' ] = basename ( $ original_filename ) ; } } else { $ file_content = @ file_get_contents ( $ file [ 'file' ] ) ; } if ( $ file_content !== false && ! empty ( $ file_content ) ) { $ output .= $ this -> boundaryDelimiterLine ( 'multipart/mixed' ) . $ this -> contentInfoString ( $ file [ 'mime-type' ] , $ file [ 'file' ] , $ file [ 'filename' ] , $ file [ 'charset' ] ) . EmailHelper :: base64ContentTransferEncode ( $ file_content ) ; } else { if ( $ this -> _validate_attachment_errors ) { if ( ! $ tmp_file === false ) { $ filename = $ original_filename ; } else { $ filename = $ file [ 'file' ] ; } throw new EmailGatewayException ( __ ( 'The content of the file `%s` could not be loaded.' , array ( $ filename ) ) ) ; } } if ( ! $ tmp_file === false ) { General :: deleteFile ( $ tmp_file ) ; } } return $ output ; }
Builds the attachment section of a multipart email.

Will return a string containing the section. Can be used to send to
an email server directly.

@throws EmailGatewayException
@throws Exception
@return string
Builds the attachment section of a multipart email .