protected function createSwiftSigner($signature)
    {
        if (!isset($signature['type'])) {
            throw new InvalidConfigException('Signature configuration should contain "type" key');
        }
        switch (strtolower($signature['type'])) {
            case 'dkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_DKIMSigner($privateKey, $domain, $selector);
            case 'opendkim' :
                $domain = ArrayHelper::getValue($signature, 'domain', null);
                $selector = ArrayHelper::getValue($signature, 'selector', null);
                if (isset($signature['key'])) {
                    $privateKey = $signature['key'];
                } elseif (isset($signature['file'])) {
                    $privateKey = file_get_contents(Yii::getAlias($signature['file']));
                } else {
                    throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
                }
                return new \Swift_Signers_OpenDKIMSigner($privateKey, $domain, $selector);
            default:
                throw new InvalidConfigException("Unrecognized signature type '{$signature['type']}'");
        }
    }