lib/Mailer.php
private function doSend(MessageInterface $message)
    {
        $content = $this->format($message);
        $headers = $this->getHeaders();
        $files = $this->getFiles($message);

        if (!empty($files)) {
            // HTTP query content
            parse_str($content, $fields);
            $builder = new MultipartStreamBuilder();

            foreach ($fields as $name => $value) {
                if (is_array($value)) {
                    foreach ($value as $c) {
                        $builder->addResource($name.'[]', $c);
                    }
                    continue;
                }

                $builder->addResource($name, $value);
            }

            // Add files to request
            foreach ($files as $key => $items) {
                foreach ($items as $name => $path) {
                    $options = [];
                    if (!is_numeric($name)) {
                        $options['filename'] = $name;
                    }
                    $value = fopen($path, 'r');
                    $builder->addResource($key, $value, $options);
                }
            }

            $content = $builder->build();
            $headers['Content-Type'] = 'multipart/form-data; boundary="'.$builder->getBoundary().'"';
        }

        $request = $this->getMessageFactory()->createRequest('POST', $this->getEndpoint(), $headers, $content);

        return $this->getHttpClient()->sendRequest($request);
    }
private function doSend(MessageInterface $message)
    {
        $content = $this->format($message);
        $headers = $this->getHeaders();
        $files = $this->getFiles($message);

        if (!empty($files)) {
            // HTTP query content
            parse_str($content, $fields);
            $builder = new MultipartStreamBuilder();

            foreach ($fields as $name => $value) {
                if (is_array($value)) {
                    foreach ($value as $c) {
                        $builder->addResource($name.'[]', $c);
                    }
                    continue;
                }

                $builder->addResource($name, $value);
            }

            // Add files to request
            foreach ($files as $key => $items) {
                foreach ($items as $name => $path) {
                    $options = [];
                    if (!is_numeric($name)) {
                        $options['filename'] = $name;
                    }
                    $value = fopen($path, 'r');
                    $builder->addResource($key, $value, $options);
                }
            }

            $content = $builder->build();
            $headers['Content-Type'] = 'multipart/form-data; boundary="'.$builder->getBoundary().'"';
        }

        $request = $this->getMessageFactory()->createRequest('POST', $this->getEndpoint(), $headers, $content);

        return $this->getHttpClient()->sendRequest($request);
    }
Take a Message and return a PSR ResponseInterface.

@param MessageInterface $message

@return ResponseInterface