从php.ini配置SMTP主机

I'm trying to configure SwiftMailer's SMTP transport by looking at php.ini. I've tried creating a compilerpass to alter the mailer_host parameter, but the changed value doesn't seem to influence the container that gets built.

On a second attempt, I tried requesting the service definition for swiftmailer.mailer.default.transport."something", but can't seem to find the correct service either.

Any pointers?

Thanks

Ok, I found out that I can alter the configuration of other bundles using the PrependExtensionInterface. After implementing that interface in my own extension, I could just do this:

public function prepend(ContainerBuilder $container)
{
    $container->prependExtensionConfig(
        'swiftmailer', 
        array ('host' => ini_get('SMTP'))
    );
}

I'm aware there are probably better solutions for this. For instance, placing the swiftmailer configuration in a server-wide .yml file and including that. That would offer more flexibility etc., but for now, this is fine.