/**
  * @param \common\commands\SendEmailCommand $command
  * @return bool
  */
 public function handle($command)
 {
     if (!$command->body) {
         $message = \Yii::$app->mailer->compose($command->view, $command->params);
     } else {
         $message = new Message();
         if ($command->isHtml()) {
             $message->setHtmlBody($command->body);
         } else {
             $message->setTextBody($command->body);
         }
     }
     $message->setFrom($command->from);
     $message->setTo($command->to ?: \Yii::$app->params['robotEmail']);
     $message->setSubject($command->subject);
     return $message->send();
 }
 /**
  * @depends testGetSwiftMessage
  */
 public function testSetGet()
 {
     $message = new Message();
     $charset = 'utf-16';
     $message->setCharset($charset);
     $this->assertEquals($charset, $message->getCharset(), 'Unable to set charset!');
     $subject = 'Test Subject';
     $message->setSubject($subject);
     $this->assertEquals($subject, $message->getSubject(), 'Unable to set subject!');
     $from = '*****@*****.**';
     $message->setFrom($from);
     $this->assertContains($from, array_keys($message->getFrom()), 'Unable to set from!');
     $replyTo = '*****@*****.**';
     $message->setReplyTo($replyTo);
     $this->assertContains($replyTo, array_keys($message->getReplyTo()), 'Unable to set replyTo!');
     $to = '*****@*****.**';
     $message->setTo($to);
     $this->assertContains($to, array_keys($message->getTo()), 'Unable to set to!');
     $cc = '*****@*****.**';
     $message->setCc($cc);
     $this->assertContains($cc, array_keys($message->getCc()), 'Unable to set cc!');
     $bcc = '*****@*****.**';
     $message->setBcc($bcc);
     $this->assertContains($bcc, array_keys($message->getBcc()), 'Unable to set bcc!');
 }