Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Handle "mailer" in swiftmailer:email:send #88

Closed
ZCJ opened this issue Dec 3, 2014 · 0 comments
Closed

Handle "mailer" in swiftmailer:email:send #88

ZCJ opened this issue Dec 3, 2014 · 0 comments

Comments

@ZCJ
Copy link

ZCJ commented Dec 3, 2014

By default, the mailer will use the 'default' value for the mailer option.
->addOption('mailer', null, InputOption::VALUE_REQUIRED, 'The mailer name', 'default')
When executing swiftmailer: email: send , i was not prompt to enter/confirm/validate my 'mailer', and hence the command was throwing an error :

PHP Fatal error: Call to undefined method Symfony\Bundle\SwiftmailerBundle\Command\NewEmailCommand::getOption() in /Users/ZCJ/Sites/Spade/vendor/symfony/swiftmailer-bundle/Command/NewEmailCommand.php on line 61

That was because my mail service was configured as "gmail" and an exception was being raised in:
$mailerServiceName = sprintf('swiftmailer.mailer.%s', $input->getOption('mailer'));
if (!$this->getContainer()->has($mailerServiceName)) {
throw new \InvalidArgumentException(sprintf('The mailer "%s" does not exist', $this->getOption('mailer')));
}

I think it would be great if we can handle the mailer in the interact dialog.

For that, I am proposing something minor like :

if('default' === $input->getOption('mailer')){
$input->setOption('mailer',$dialog->ask($output, sprintf('Mailer (Enter for 'default'): '),'default'));
}

This was referenced Dec 3, 2014
@fabpot fabpot closed this as completed Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants