I have the following configuration set in my factories.yml file...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
...to overcome the 'double dot' issue as described here.
When I run the following code...
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('[email protected]');
$message->setFrom('[email protected]');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
...inside an action everything works as expected. But when I run the same code from inside a task, I get a fatal error - PHP Fatal error: Call to undefined method getCommand
- because SwiftMailer is using the default transport class and not the Swift_SendmailTransport
class as specified in the factories.yml configuration.
Any ideas why the factories.yml configuration isn't loaded in a symfony task, and how I can go about solving this issue?