public function appendAttachment($file)
    {
        if (!is_array($file)) {
            // treat the param as string (old format)
            $file = array(
                'file' => $file,
                'filename' => null,
                'charset' => null,
            );

            // is array, but not the right key
        } elseif (!isset($file['file'])) {
            // another (un-documented) old format: key is filename
            $keys = array_keys($file);
            $file = array(
                'file' => $file[$keys[0]],
                'filename' => is_numeric($keys[0]) ? null : $keys[0],
                'charset' => null,
            );
        }

        // push properly formatted file entry
        $this->_attachments[] = $file;
    }
public function appendAttachment($file)
    {
        if (!is_array($file)) {
            // treat the param as string (old format)
            $file = array(
                'file' => $file,
                'filename' => null,
                'charset' => null,
            );

            // is array, but not the right key
        } elseif (!isset($file['file'])) {
            // another (un-documented) old format: key is filename
            $keys = array_keys($file);
            $file = array(
                'file' => $file[$keys[0]],
                'filename' => is_numeric($keys[0]) ? null : $keys[0],
                'charset' => null,
            );
        }

        // push properly formatted file entry
        $this->_attachments[] = $file;
    }
public function appendAttachment ( $ file ) { if ( ! is_array ( $ file ) ) { // treat the param as string (old format) $ file = array ( 'file' => $ file , 'filename' => null , 'charset' => null , ) ; // is array, but not the right key } elseif ( ! isset ( $ file [ 'file' ] ) ) { // another (un-documented) old format: key is filename $ keys = array_keys ( $ file ) ; $ file = array ( 'file' => $ file [ $ keys [ 0 ] ] , 'filename' => is_numeric ( $ keys [ 0 ] ) ? null : $ keys [ 0 ] , 'charset' => null , ) ; } // push properly formatted file entry $ this -> _attachments [ ] = $ file ; }
Appends one file attachment to the attachments array.

@since Symphony 2.3.5

@param string|array $file
Can be a string representing the file path, absolute or relative, i.e.
`'http://example.com/foo.txt'` or `'path/to/your/webspace/foo/bar.csv'`.

Can also be a keyed array. This will enable more options, like setting the
charset used by mail agent to open the file or a different filename.

Example:
````
$email->appendAttachment(array(
'file' => 'http://example.com/foo.txt',
'filename' => 'bar.txt',
'charset' => 'UTF-8',
'mime-type' => 'text/csv',
));
````
Appends one file attachment to the attachments array .