在symfony4上安装了带有composer的swiftmailer后
composer require mailer
我写了一个小函数来测试它
/**
* @Route("/testmail", name="testmail")
*/
public function mailAction(\Swift_Mailer $mailer)
{
$message = (new \Swift_Message('Hello Email'))
->setFrom('test@gmail.com')
->setTo('test@gmail.com')
->setBody('Test content')
;
$mailer->send($message);
return $this->redirectToRoute('rotta');
}
在.env
中相应地配置了邮件程序URLMAILER_URL=gmail://myaccount:mypassword@localhost
但通过调用我的函数,我收到以下错误消息
Cannot determine controller argument for "App\Controller\RottaController::mailAction()": the $mailer argument is type-hinted with the non-existent class or interface: "Swift_Mailer".
执行时
./bin/console debug:config framework
Swiftmailer没有出现,服务注册失败了吗?我该怎么检查?
感谢 塞巴斯蒂安