src/Message/Helper/MultipartHelper.php
public function createAndAddPartForAttachment(Message $message, $resource, $mimeType, $disposition, $filename = null)
    {
        if ($filename === null) {
            $filename = 'file' . uniqid();
        }

        $safe = iconv('UTF-8', 'US-ASCII//translit//ignore', $filename);
        if ($message->isMime()) {
            $builder = $this->partBuilderFactory->newPartBuilder($this->mimePartFactory);
            $builder->addHeader('Content-Transfer-Encoding', 'base64');
            if (strcasecmp($message->getContentType(), 'multipart/mixed') !== 0) {
                $this->setMessageAsMixed($message);
            }
            $builder->addHeader('Content-Type', "$mimeType;\r\n\tname=\"$safe\"");
            $builder->addHeader('Content-Disposition', "$disposition;\r\n\tfilename=\"$safe\"");
        } else {
            $builder = $this->partBuilderFactory->newPartBuilder(
                $this->uuEncodedPartFactory
            );
            $builder->setProperty('filename', $safe);
        }
        $part = $builder->createMessagePart();
        $part->setContent($resource);
        $message->addChild($part);
    }
public function createAndAddPartForAttachment(Message $message, $resource, $mimeType, $disposition, $filename = null)
    {
        if ($filename === null) {
            $filename = 'file' . uniqid();
        }

        $safe = iconv('UTF-8', 'US-ASCII//translit//ignore', $filename);
        if ($message->isMime()) {
            $builder = $this->partBuilderFactory->newPartBuilder($this->mimePartFactory);
            $builder->addHeader('Content-Transfer-Encoding', 'base64');
            if (strcasecmp($message->getContentType(), 'multipart/mixed') !== 0) {
                $this->setMessageAsMixed($message);
            }
            $builder->addHeader('Content-Type', "$mimeType;\r\n\tname=\"$safe\"");
            $builder->addHeader('Content-Disposition', "$disposition;\r\n\tfilename=\"$safe\"");
        } else {
            $builder = $this->partBuilderFactory->newPartBuilder(
                $this->uuEncodedPartFactory
            );
            $builder->setProperty('filename', $safe);
        }
        $part = $builder->createMessagePart();
        $part->setContent($resource);
        $message->addChild($part);
    }
public function createAndAddPartForAttachment ( Message $ message , $ resource , $ mimeType , $ disposition , $ filename = null ) { if ( $ filename === null ) { $ filename = 'file' . uniqid ( ) ; } $ safe = iconv ( 'UTF-8' , 'US-ASCII//translit//ignore' , $ filename ) ; if ( $ message -> isMime ( ) ) { $ builder = $ this -> partBuilderFactory -> newPartBuilder ( $ this -> mimePartFactory ) ; $ builder -> addHeader ( 'Content-Transfer-Encoding' , 'base64' ) ; if ( strcasecmp ( $ message -> getContentType ( ) , 'multipart/mixed' ) !== 0 ) { $ this -> setMessageAsMixed ( $ message ) ; } $ builder -> addHeader ( 'Content-Type' , "$mimeType;\r\n\tname=\"$safe\"" ) ; $ builder -> addHeader ( 'Content-Disposition' , "$disposition;\r\n\tfilename=\"$safe\"" ) ; } else { $ builder = $ this -> partBuilderFactory -> newPartBuilder ( $ this -> uuEncodedPartFactory ) ; $ builder -> setProperty ( 'filename' , $ safe ) ; } $ part = $ builder -> createMessagePart ( ) ; $ part -> setContent ( $ resource ) ; $ message -> addChild ( $ part ) ; }
Creates and adds a MimePart for the passed content and options as an
attachment.

@param Message $message
@param string|resource|Psr\Http\Message\StreamInterface\StreamInterface
$resource
@param string $mimeType
@param string $disposition
@param string $filename
@return \ZBateson\MailMimeParser\Message\Part\MimePart
Creates and adds a MimePart for the passed content and options as an attachment .