Send email by console use transport

Hi,

I want send email by console with Swift_SmtpTransport. This work in common and don’t work in console.

In console in config/main-local.php I have:



<?php


return [


    'components' => [        


        'mail' => [


            'class' => 'yii\swiftmailer\Mailer',


            'viewPath' => '@common/mail',


            'htmlLayout' => '@common/mail/layouts/html',


            'textLayout' => '@common/mail/layouts/text',  // custome layout        


            'transport' => [


                'class' => 'Swift_SmtpTransport',


                'host' => 'gator.hostgator.com',


                'username' => 'test@pix.com',


                'password' => '*******',


                'port' => '465',


                'encryption' => 'ssl',


            ],


        ],


    ],    


];


With this configuration I load the script by command and no email send and no error.

With this (I delete the transport) I run the same script by command I the email send ok:



<?php


return [


    'components' => [        


        'mail' => [


            'class' => 'yii\swiftmailer\Mailer',


            'viewPath' => '@common/mail',


            'htmlLayout' => '@common/mail/layouts/html',


            'textLayout' => '@common/mail/layouts/text',  // custome layout        


        ],


    ],    


];


In console/controllers/CronController I have this:



<?php


 


namespace console\controllers;


 


use yii\console\Controller;


use backend\models\Definicoes;


use common\models\Acordo;


use Yii;


 


/**


 * Cron controller


 */


class CronController extends Controller {


 


    public function actionIndex() {


        $data_hoje = date('Y-m-d');


        $model_definicoes = Definicoes::find()->one();


        


        Yii::$app->mail->compose('@common/mail/cron_acordo', ['model_definicoes' => $model_definicoes])


           ->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->params['nome']])


           ->setSubject('Alert')


           ->setTo('ideinto@gmail.com')     


           ->send();        


    }


}


Why this happen? I can´t use transport in console? I use the same transport setting in common and Yii send email ok.

Thanks!



php -v command


PHP 5.4.45 (cli) (built: Oct  5 2015 15:35:12)


Copyright (c) 1997-2014 The PHP Group


Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies


    with the ionCube PHP Loader v4.7.4, Copyright (c) 2002-2014, by ionCube Ltd., and


    with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies


| Yii version: 2.0.7 |

| Operating system: Linux |