php - Symfony 4 + Swift Mailer - 从 127.0.0.1 发送电子邮件时出错
问题描述
Symfony 4 应用程序使用 Swift Mailer 发送电子邮件。
我已经编写了我的控制器逻辑并创建了一个表单,电子邮件都在生产服务器上工作。
但是在开发模式下运行时php bin/console server:run
出现错误:
Service "logger" not found: even though it exists in the app's container, the container inside "App\Controller\PageController" is a smaller service locator that only knows about the "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session" and "twig" services.
Try using dependency injection instead.
我只是按原样使用捆绑包。为什么我不能从本地开发环境发送电子邮件?
解决方案
您以某种方式替换了 Symfony 内部的默认容器App\Controller\PageController
。此消息基本上意味着对象未在容器中设置其依赖项。详情请看这里:https ://symfony.com/doc/current/service_container.html
Symfony 使用容器模式,它将许多对象保存在一个容器中,可以通过整个应用程序访问。
推荐阅读
- python-3.x - 检查目标时出错:预期 dense_2 的形状为 (45, 20) 但得到的数组的形状为 (45, 1)
- python - 如何从文本文件中为不同的功能运行计数
- amadeus - 航班预订确认
- matlab - 是否可以在 Matlab 中绘制带有填充图案的条形图
- python - ModuleNotFoundError:没有以 virtualenv 命名的模块,需要了解如何为生产构建它
- python - 切片张量的每个原始数据
- sql - SQL - 多部分标识符错误:无法绑定多部分标识符“OBDATE.SUMMARY_BLOCK_ID”
- javascript - Javascript数组对象到逗号分隔的单行数组
- python - 轻松阅读行“参数”
- vb.net - 如果出现带有特定数字的标签,如何将图片框从可见更改为不可见?