Home > Net >  SwiftMailer spool:send command - how to see details about sent messages? Verbose option not working
SwiftMailer spool:send command - how to see details about sent messages? Verbose option not working

Time:10-17

Here is the output of the --help option for SwiftMailer's send command:

$ php bin/console swiftmailer:spool:send -help
Description:
  Sends emails from the spool

Usage:
  swiftmailer:spool:send [options]

Options:
      --message-limit=MESSAGE-LIMIT      The maximum number of messages to send.
      --time-limit=TIME-LIMIT            The time limit for sending messages (in seconds).
      --recover-timeout=RECOVER-TIMEOUT  The timeout for recovering messages that have taken too long to send (in seconds).
      --mailer=MAILER                    The mailer name.
      --transport=TRANSPORT              The service of the transport to use to send the messages.
  -h, --help                             Display this help message
  -q, --quiet                            Do not output any message
  -V, --version                          Display this application version
      --ansi                             Force ANSI output
      --no-ansi                          Disable ANSI output
  -n, --no-interaction                   Do not ask any interactive question
  -e, --env=ENV                          The Environment name. [default: "prod"]
      --no-debug                         Switches off debug mode.
  -v|vv|vvv, --verbose                   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  The swiftmailer:spool:send command sends all emails from the spool.

  php bin/console swiftmailer:spool:send --message-limit=10 --time-limit=10 --recover-timeout=900 --mailer=default

I'd like to run this with debug-level verbosity. However I am getting the exact same output as when I run the command normally:

$ php bin/console swiftmailer:spool:send -vvv

 [2021-10-15 12:11:22] Processing default mailer spool...
 2 emails sent

I would expect verbose option to at least display some details about the message being sent... Does anyone know what kind of output the different verbosity levels are supposed to display? Am I doing using it incorrectly and if so what's the right way to get verbose output?

CodePudding user response:

Verbosity level isn't tied to a specific command. It's a part of symfony/console component and just a way to give you (as developer) controls to react to users' input.

Not all provided commands take an advantage of and do not always react to it. If you look inside Symfony\Bundle\SwiftmailerBundle\Command\SendEmailCommand.php you won't find neither

if($this->io->getVerbosity()) { //... }

nor

if($this->io->isVerbose()) { //... }

nor

if($this->io->isVeryVerbose()) { //... }

So there's simply no logic for -vvv in swiftmailer:spool:send

So in general, higher verbosity will simply give you more information about error, e.g. stack trace if any exception is thrown. ...unless you implemented some checks in your own commands.

  • Related