我尝试将多个邮件程序添加到我的项目中,如in the symfony documentation所述 . 但是当我尝试访问其中一个邮件如 $container->get('swiftmailer.mailer.first_mailer'); 时,我收到以下错误:

The "swiftmailer.mailer.first_mailer" service or alias has been removed or inlined when 
the container was compiled. You should either make it public, or stop using
the container directly and use dependency injection instead.

我知道使用容器不再是一个好习惯,symfony建议使用依赖注入 . 但我无法找到一种方法来声明在注入期间使用哪些已定义的邮件程序,也无法将 services._defaults.public 设置为 true ,因为框架无法再自动装配某些类 .

我在symfony文档中找不到关于这个主题的任何内容 .

有没有办法将swiftmailer服务设置为public并使用symfony 4中的容器访问它们?