Symfony 1.4动态/编程为swiftmailer设置delivery_strategy

So I am working on Symfony 1.4 and I am looking for a way to programmatically set a different delivery_strategy than what I have in my factories.yml.

My code for initialising the mailer and the transport is as below:

$transport  = Swift_SmtpTransport::newInstance('MY SMTP SERVER');
$transport->setUsername($api_user);        
$transport->setPassword($api_key);        
$swift      = Swift_Mailer::newInstance($transport);                        
$response   = $swift->send($message);

For example in my factories.yml I have the strategy set to spool but here I want to set it to realtime.

Any way of doing this programmatically?

Real-time means it'll be sent right away. So the code you're already using should do that. The documentation link have more info swiftmailer.org/docs/sending.html.

Delivery strategy is a Symfony concept. Swiftmailer does not have it. All you send using Swiftmailer directly will be sent right away, corresponding to the Symfony 'realtime' delivery strategy.