public function deliver($swiftMessage, $transport = null)
    {
        // get the transport
        if (!$transport)
            $transport = $this->defaultTransport;
        if (!isset($this->transports[$transport]))
            throw new CException(Yii::t('email', 'Transport :transport is not configured.', array(':transport' => $transport)));

        // get transport options
        $options = $this->transports[$transport];

        // get transport class
        if (isset($options['class'])) {
            $class = $options['class'];
            unset($options['class']);
        } else {
            throw new CException(Yii::t('email', 'Transport :transport does not have a class.', array(':transport' => $transport)));
        }

        // get transport setters
        if (isset($options['setters'])) {
            $setters = $options['setters'];
            unset($options['setters']);
        } else {
            $setters = array();
        }

        // create a new transport using class, options and setters
        $swiftTransport = call_user_func_array($class . '::newInstance', $options);
        foreach ($setters as $k => $v) {
            call_user_func_array(array($swiftTransport, 'set' . ucfirst($k)), array($v));
        }

        // send the message using the transport
        return Swift_Mailer::newInstance($swiftTransport)->send($swiftMessage);
    }