symfony / swiftmailer-bundle

Symfony Swiftmailer Bundle
https://symfony.com/swiftmailer-bundle
MIT License
1.56k stars 151 forks source link

Spool:send command ignores environment with spool's type 'file' #247

Closed proArtex closed 2 years ago

proArtex commented 6 years ago

Symfony: 4.0.11 Bundle: 3.2.2

Here is my config:

swiftmailer:
    url: '%env(MAILER_URL)%'
    spool:
        type: 'file'
        path: '%kernel.project_dir%/var/mails'

and command: bin/console swiftmailer:spool:send --env=dev

It sends emails generated by any environment.

kojidev commented 5 years ago

--env argument means that Kernel will be initiated with that environment, and is common argument for every console command. It has no idea which mails you sent from where. If you want to send mail from different environments then you have to set up different spools/spool paths per environment:

swiftmailer.yaml:

swiftmailer:
    spool:
        type: 'file'
        path: '%kernel.project_dir%/var/%kernel.environment%/mails'
proArtex commented 5 years ago

If it works so, it's better to mention this fact in documentation. At least with path you've provided.

kojidev commented 5 years ago

Why tho? You just could check out var/mails folder to find out that there's nothing about environments, just mail files. If you think it is a common case and the code sample would be better with %kernel.environment in it you can send a PR. If your issue is resolved you can close it.

fabpot commented 2 years ago

Closing as Swiftmailer is not maintained anymore and in any case, the spool feature of Swiftmailer was really weak. Migrating to Symfony Mailer would give a way better way to send emails async.