Symfony2 Monolog到电子邮件错误为什么swiftmailer.transport.real不存在

 王婷山东理工_441_796 发布于 2023-02-04 12:52

从更新symfony后2.32.4我得到了ServiceNotFoundException

 Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException' with message 'The service "monolog.handler.mojhandler" has a dependency on a non-existent service "swiftmailer.transport.real".' in E:\wamp\www\project\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php on line 59

这是我的config_prod.yml

imports:
    - { resource: config.yml }
monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      streamed
        streamed:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        mail:
            type:         fingers_crossed
            action_level: error
            handler:      buffered
            channels: ["!app"] # Dont log app because we dont' want 404 errors sending
        buffered:
            type:    buffer
            handler: mojhandler
        mojhandler:
            type:       swift_mailer
            from_email: %mojhandler_logger_email%
            to_email:   %mojhandler_logger_email%
            subject:    "[Panel] An Error Occurred!"
            level:      debug

这是来自config.yml的我的swiftmailer配置

# Swiftmailer Configuration
swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    port:      %mailer_port%
    auth_mode: %mailer_auth_mode%
    encryption: %mailer_encryption%

我该如何解决?

1 个回答
  • 如果不在swiftmailer配置中设置'spool'配置值,那似乎确实是一个错误。

    为了解决这个问题,我不得不自己在其中一个services.yml中创建缺少的服务(因为我不想使用假脱机):

    swiftmailer.transport.simplemailinvoker:
        class: Swift_Transport_SimpleMailInvoker
    
    swiftmailer.transport.eventdispatcher:
        class: Swift_Events_SimpleEventDispatcher
    
    swiftmailer.transport.real:
        class: Swift_Transport_MailTransport
        arguments: [@swiftmailer.transport.simplemailinvoker, @swiftmailer.transport.eventdispatcher]
    

    2023-02-04 12:55 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有