public static function deliver($to = null, $subject = null, $message = null, $config = 'default', $send = true)
    {
        $class = __CLASS__;

        if (is_array($config) && !isset($config['transport'])) {
            $config['transport'] = 'default';
        }
        /* @var \Cake\Mailer\Email $instance */
        $instance = new $class($config);
        if ($to !== null) {
            $instance->setTo($to);
        }
        if ($subject !== null) {
            $instance->setSubject($subject);
        }
        if (is_array($message)) {
            $instance->setViewVars($message);
            $message = null;
        } elseif ($message === null && array_key_exists('message', $config = $instance->getProfile())) {
            $message = $config['message'];
        }

        if ($send === true) {
            $instance->send($message);
        }

        return $instance;
    }