php - 无法在 Monolog 的 yaml 配置中为 native_mailer 设置 content_type?

标签 php symfony monolog

我目前正在尝试使用 Monolog 通过 PHP 的 native 邮件程序将未捕获的异常以 HTML 格式通过电子邮件发送给我。我收到的电子邮件很好,但 HTML 是纯文本,内容类型似乎设置为 text/plain 而我无法将 content_type 设置为 text/html 通过 yaml 配置。

我的 monolog.yaml 看起来像这样:

monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: ["!event"]
        console:
            type:   console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine", "!console"]
        system_logger:
            type: native_mailer
            from_email: 'Some email here'
            to_email: 'my_email_address@test.com'
            subject: 'Uncaught exception'
            formatter: monolog.formatter.html
            level: error
            content_type: text/html   # this is not supported?

查看 Monolog 的 NativeMailerHandler,它确实有一个 setContentType 函数,但我如何通过 yaml 配置访问它?

最佳答案

在(未成功)尝试将 native_mailercontent_type 设置为 html/text 一段时间后,我刚刚切换到 swift_mailer 代替。

关于php - 无法在 Monolog 的 yaml 配置中为 native_mailer 设置 content_type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50943638/

相关文章:

Symfony3+PHP单元。如何禁用控制台中的调试日志?

PHP如何执行命令

symfony - Twig Symfony2获取请求变量

Symfony Autowiring 独白 channel

php - Laravel 独白。记录 INFO 级别到单独的文件

symfony - 检查定义是否有方法,添加(或不添加)方法调用?

php - 需要重新审视 mysql 查询语句

javascript - 如何保护 ajax 调用(JS 到 PHP)

php - 执行shell命令在后台运行php

php - Symfony 4.3 : User Deprecated: The Symfony\Bundle\TwigBundle\Loader\FilesystemLoader class is deprecated since version 4. 3 并将在 5.0 中删除...