Giter Site home page Giter Site logo

Comments (4)

weaverryan avatar weaverryan commented on August 16, 2024

Probably that value is read at container build time to change a service definition. It would likely require some reworking so that it’s read at runtime.

from swiftmailer-bundle.

samfahmie avatar samfahmie commented on August 16, 2024

That's what my analysis showed. I was going to try to create a simple fix and just submit a PR but it looks like the way to solve it likely involves storing the value in parameters and referencing it at runtime when attempting to send mail instead.

from swiftmailer-bundle.

arno14 avatar arno14 commented on August 16, 2024

I have not been able to disable/enable mail delivery with Env vars on a project with Symfony 4.3.4
file .env

SWIFTMAILER_DISABLE_DELIVERY=1

file config/packages/swiftmailer.yml

swiftmailer:
    disable_delivery: '%mailer_disable_delivery%'  

file config/services.yml

parameters:
    swiftmailer_disable_delivery: "%env(bool:SWIFTMAILER_DISABLE_DELIVERY)%"

This config does not work.
Even if calling $container->getParameter('swiftmailer_disable_delivery') return the correct value regarding the env vars.
When processing config, the swiftmailer bundle always consider that this value is true (as it is a string whose content is "%env...", see https://github.com/symfony/swiftmailer-bundle/blob/master/DependencyInjection/SwiftmailerExtension.php#L83.)

I solved the problem in creating the parameter in a php file( and removing the parameter from services.yml).

file config/services.php

<?php
$container->setParameter('swiftmailer_disable_delivery', (bool)getenv('SWIFTMAILER_DISABLE_DELIVERY'));

This require to clear the cache.
An other solution would be to create a good old file called "parameters.yml" that would not be commited (in addition to the also uncommited ".env.local" file).

from swiftmailer-bundle.

fabpot avatar fabpot commented on August 16, 2024

Closing as this bundle is not maintained anymore.

from swiftmailer-bundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.