-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add Mailer send and debug commands #43687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
Oh I see, didn't find the existing issues/PRs before.
@fabpot I agree with the comments in previous PRs, i.e. that it is a helpful tool to test sending of emails in your application - and we have used it as such in numerous projects with Swiftmailer Bundle. Since we switched from Swiftmailer to Symfony Mailer in Contao 4.10 and up however, this feature is sorely missed by us and other members of the Contao community. If the decision is (again) made to not include this, we can of course instead provide a command within Contao. |
31adda6
to
9982509
Compare
@fabpot Why 6.2 and not 6.1 ? Thanks you for advance. |
@vinceAmstoutz 6.1 is in feature freeze, so only bug fixes will be fixed until 6.1 is out (end of this month) |
@FabienPapet I think the question is why this has been moved from 5.4 to 6.1 and then from 6.1 to 6.2, i.e. is there still any intention of merging this? There was no feedback to my last comment and thus I haven't followed up here and did not fix the conflict yet. |
Exactly, thx ! |
See @fritzmg response. Thx for advance |
I think this is a miss for this PR to not be reviewed, but I guess as this PR has not been updated, It has been forgotten, and now moved to 6.2. I'd also really liked to see this feature in 6.1 as i always create a mail:send command in all my projects but I saw this PR only today :/ |
This feature has been rejected for almost two years now - I did not want to put in any additional effort before confirming that it will now finally make it in. |
I understand that, I think we need to (re)consider that again after 2 years ? Maybe open a RFC for this ? |
Open where? I just need a confirmation from @fabpot (or whoever) here that Symfony is interested in merging this and then I can continue working on this PR. |
In any case you can now install |
It's still sad to come to this! I regret (although I love the Framework ;) ) the management of this @fabpot @FabienPapet ticket. It's not nice to leave people in the dark and in doubt for so long ... Sincerely. |
ping @nicolas-grekas @chalasr , It looks like no one from the core team has been giving it's opinion on this. Any help ? :) |
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
->addOption('transport', null, InputOption::VALUE_OPTIONAL, 'The transport to be used') | ||
->addOption('content-type', null, InputOption::VALUE_REQUIRED, 'The body content type of the message', 'text/plain') | ||
->addOption('charset', null, InputOption::VALUE_REQUIRED, 'The body charset of the message', 'utf-8') | ||
->addOption('body-source', null, InputOption::VALUE_REQUIRED, 'The source of the body [stdin|file]', 'stdin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would only support stdin as it also allows to get content from a file.
General question: I originally put the command(s) in |
7a0a90a
to
2931282
Compare
Closing in favor of #47040 which implements a command that eases testing sending an email instead of trying to have a semi-generic command to send emails. It should be enough to cover the use cases mentioned here, and as a bonus, it bypasses the message bus to ease testing. |
This PR was merged into the 6.2 branch. Discussion ---------- Add a mailer:test command | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #43687, Fix #39173, Fix #37409 | License | MIT | Doc PR | This PR introduces a `mailer:test` command that helps test if sending emails works correctly. The only argument is the `To` header. Everything is optional. There is no support for complex emails (STDIN for body, HTML support, attachments, ...) as the goal is to test if a transport works correctly. Note that this command bypasses the Messenger bus if configured to ease testing even when the messenger consumer is not running. Commits ------- dee0d09 Add a mailer:test command
The old and deprecated Swiftmailer Bundle had a few useful features that are still absent with the current Symfony Mailer implementation: for instance being able to quickly test your email configuration by sending a test email via the command line.
This PR provides a
mailer:send
andmailer:debug
command. The implementation is more or less copied over from the Swiftmailer Bundle.mailer:send
interactively asks you for the sender address, recipient address, subject and message body and then sends the email via the default mailer transport. Additionally you can set the chosen transport via--transport
for example, if you use multiple mailer transports.mailer:debug
shows you name and DSN of all your configured mailer transports (or just name and DSN of a specified transport).Discussion
Currently there is no way to retrieve the available mailer transports from the container. By contrast the Swiftmailer Bundle registers each individual transport in the container as a service, which can then be retrieved in the commands. In the current Mailer implementation they are only passed to
mailer.transports
and cannot be retrieved otherwise (or at least I could not figure out how). This PR implements agetTransports
method for theTransports
class, however I suppose it should be done differently (new interface?).