Skip to content

env processing and DI problem in monolog mailer config with multiple addresses #39499

Closed
@mmarton

Description

@mmarton

Hi!

Symfony version(s) affected: 5.2

Description
I'd like to set multiple to addresses to monolog email handler from env config.
I have the following monolog configuration:

monolog:
    handlers:
        email:
            type: fingers_crossed
            action_level: critical
            handler: deduplicated
        deduplicated:
            type: deduplication
            handler: symfony_mailer
        symfony_mailer:
            type: symfony_mailer
            content_type: text/html
            from_email: 'from@email.com'
            to_email: '%env(json:EXCEPTION_EMAIL_ADDRESSES)%'
            subject: 'Exception %%message%%'
            level: debug
            formatter: monolog.formatter.html

and env file with:
EXCEPTION_EMAIL_ADDRESSES='["address1@email.com","address2@email.com"]'

problem:
the config normalizer runs before the env processing here
https://github.com/symfony/monolog-bundle/blob/master/DependencyInjection/Configuration.php#L610
and sees my to_email as a string: string(79) "env_777f8e4b1e96b241_EXCEPTION_EMAIL_ADDRESSES_1787d55fa4dbd016b8b6bb36ab5f3002"
and wraps it into an array

passing an array of email directly to the config works as expected:
to_email: ["address1@email.com","address2@email.com"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions