我的 factory.yml 文件中设置了以下配置...
all:
mailer:
param:
transport:
class: Swift_SendmailTransport
param:
command: /usr/sbin/sendmail -oi -t
...克服此处描述的“双点”问题。
当我运行以下代码时...
$mailer = $this->getMailer();
$message = $mailer->compose();
$message->setTo('foo@bar.com');
$message->setFrom('foo@bar.com');
$message->setSubject('Testing');
$message->setBody(
$mailer->getRealtimeTransport()->getCommand(),
'text/plain'
);
$mailer->send($message);
...在一个动作中,一切都按预期工作。但是当我从任务内部运行相同的代码时,我得到一个致命错误PHP Fatal error: Call to undefined method getCommand
- 因为 SwiftMailer 使用的是默认传输类,而不是 factory.ymlSwift_SendmailTransport
配置中指定的类。
为什么没有在 symfony 任务中加载 factory.yml 配置的任何想法,以及我该如何解决这个问题?